I’ve this database.
I want to find fourth lowest salary.
SELECT
*
FROM
employees
ORDER BY salary DESC
LIMIT 1 OFFSET (Number_of_rows_of_table-3);
I can solve this by using order by ASC pretty easily with LIMIT 1 OFFSET 3. I’m wondering if there’s an way to solve it via order by DESC?
Here’s my try which didn’t work.
SELECT
count(*) as no_of_rows_of_table, salary
FROM
employees
ORDER BY salary DESC
LIMIT 1 OFFSET (no_of_rows_of_table-3);