samedi 4 avril 2015

How to find the unique row with the largest column value?

I have a SQLite database where entries are sorted like this:



| ID | length | breadth | height | time |
1 10 20 30 123
1 10 20 15 432
2 4 2 7 543
2 4 2 8 234


As you see, the height column can vary over time. I want to get the entry with the largest height, for every unique ID in my database. Is there some way to do this in one single query, instead of looping through all id's with something like this SELECT length, breadth, height FROM table WHERE id = 1 ORDER BY height DESC LIMIT 1 ?


Aucun commentaire:

Enregistrer un commentaire