Can you LIMIT
a query from the end of the results, rather than from the beginning? In particular, I'm looking for a solution w/ Postgresql, if that makes a difference.
Allow me to clarify with an example.
Let's say I want to return the 3 oldest people in my people
table, but in ascending order of age. The best way I know how to select the 3 people returns the correct records, but in the reverse order:
SELECT * FROM people
ORDER BY age DESC
LIMIT 2
should be this way-
SELECT * FROM (
SELECT *
FROM PEOPLE
ORDER BY AGE DESC
LIMIT 3 ) X
ORDER BY AGE ASC
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With