Page 1 of 1

help needed with SELECt and max value

Posted: Tue Dec 21, 2004 7:32 am
by pelegk2
is there any way to ask for a max number :

Code: Select all

select distinct max(round_num),del_id from delivery where region_id=018 group by round_num
in this case i recive 2 max(round_num) (1 and 2 ) for the "where region_id=018 "
how can i make it so i will gt only the 1 that is realy maximux?
thnaks in advance
peleg

Posted: Tue Dec 21, 2004 8:32 am
by pedrokas
u don't need the distinct!
this way u get the max value from the table for every iqual round_num

Code: Select all

select max(round_num),del_id from delivery where region_id=018 group by round_num
if u want only the row with the max the query must be simple

Code: Select all

select max(round_num) from delivery
[mysql_man]if u need to know more than the max , u must do the query with the group by (its imperative) and with that u get the max for every distinct row in the group by...[/mysql_man]