# How To Only Display Max Value?

## Recommended Posts

Hi Please forgive me. I'm new in this. This problem I have may be very easy to resolve.But I can't. And forgive my bad english. I have a database with many values. My problem is that I just want to display the max value of two different values. (of many more)Like this exempel. I have three column name. A, B and CA is only textA B CAB 1 1CD 1 2EF 2 1GH 2 2IJ 2 3KL 3 1MN 1 3I want to display value A of every B value with max value of C.Like this...MN (B=1 and max C=3)IJ (B=2 and max C=3)KL (B=3 and max C=1)We begin with that problem. Later I want to calculate some other values.../ThanksTomas

##### Share on other sites

I'm not sure if this solves your problem, but you can order by the columns and just select the top few rows. e.g.:SELECT A FROM table ORDER BY C DESC, B DESC LIMIT 3

##### Share on other sites

I'm not sure if this solves your problem, but you can order by the columns and just select the top few rows. e.g.:SELECT A FROM table ORDER BY C DESC, B DESC LIMIT 3
There is a problem. ( I think)I dont know what the user will do with the databas.There is no limit in the values. But they will allways increase with 1.Thers is a serie like thisB=1 and C will increase with one, and I dont know when it stopBut B can have changed many times (always increased with 1) before C change when B=1.I dont know if you understand. My english is not so good./Tomas
##### Share on other sites

I'm not sure I understand, run the code I wrote and see if that works for what you're trying to do.

##### Share on other sites

I'm not sure I understand, run the code I wrote and see if that works for what you're trying to do.
I did like this.Selected the max value from BMade a loop from 1 to BDisplayed B and max value on C for each B value (1,2,3 etc)Worked for me