I am using Loopback to get my data. i have the following table:
id, name, version_number
Now i wish to find the name where the version_number
is highest.
So say i have the following data:
1, 'hello', 2
2, 'test', 1
I wish to find the record 1, 'hello', 2
From the documentation, I can't seem to find anything that matches what i need. So can anyone tell me how I would do that?
Please note that i am not looking for a find
function where we order by version_number
i am looking for a findMax
kind of function
Use FETCH FIRST
combined with ORDER BY
to find the row the the highest version_number:
select * from tablename
order by version_number desc
fetch first 1 row only