I have a simple table
| ID |Product |Version|Price|Notes|
| -- | -- |--| --| --|
| 1| Pizza| 1| 10.00| It is good|
| 2| Pizza| 2| 11.00| The best yet|
| 3| Soda| 1| 3:00| |
| 4| Hot dog| 1| 8.00| 20% meat|
| 5| Soda| 2| 3.00| Rebranded|
I want to get out the ID of the latest version of the product. Product is a text value (I have no control on this)
| ID |
| -- |
| 2|
| 4|
| 5|
I will then be using this in an IN clause hence just wanting the ID
Normally I would look to use a
group by product
, then use max(version)
, however, I am not sure how to get the ID as it is not a grouped field.
I can't guarantee that the highest version will also have the highest ID (I do not control the DB)
Asked by Davey
(1 rep)
Jul 8, 2021, 03:08 PM
Last activity: Jul 14, 2021, 09:53 PM
Last activity: Jul 14, 2021, 09:53 PM