MYSQL Select statment Order By with Group By

Posted by mouthpiec on Stack Overflow See other posts from Stack Overflow or by mouthpiec
Published on 2010-05-21T18:47:11Z Indexed on 2010/05/21 18:50 UTC
Read the original article Hit count: 196

Filed under:
|
|
|
|

I have the following simple SQL statment

SELECT id, name, value_name, value_id
FROM table
GROUP BY id
ORDER BY value_id DESC

when grouping I would like to get the value_name and value_id of the tuple where the value_id is the biggest. The way it is i am getting the smallest value. For example

1, name1, valuename, 3     (where i know that there is a value_id of 5)

Can you please help?

© Stack Overflow or respective owner

Related posts about select

Related posts about sql