I am using HSQLDB Embedded. I am an experienced coder but have scant SQL experience.
I have a table Client_History that includes a date column and a “route” column with a value {A, B, C, D, E, F}. Neither column is unique. (The primary key is an ID column.) I want to generate a report that has the 30 most recent entries.
SELECT * FROM "Client_History" ORDER BY "Date", "Route" ASC
gives me the entire table sorted by date and route (of course). Appending LIMIT 30
gives me the first 30 rows. How do I instead get the last 30 rows? The Goo Gal informs me that some SQL implementations support SELECT TOP 30 ...
but apparently not HSQLDB. How might I accomplish this?
I have a vague notion that one might sort descending, take the first 30, and then re-SELECT sorted ascending, but I have insufficient SQL skills to be able to code that.
The table is for the foreseeable future no more than a few hundred rows. Performance is not likely to be a problem, no matter how I do this.