How to count the number of rows of a table used in the query?
Go to solution
Solved by wanderingfool2,
I know not an answer, but why?
Using DESC just needlessly would complicate things and would start getting into a terrible habit to learn. Ultimately it should be followed to keep it simple, especially when learning, unless you are trying to make a super efficient query...but it fits neither case.
It would be different if you weren't allowed using LIMIT or OFFSET (as not everything supports that).
I mean if you really wanted to you could do something like
SELECT * FROM employees ORDER BY salary DESC LIMIT 1 OFFSET (SELECT count(*) FROM employees) - 3;
The above though, if I were to be marking someone on it, I would give them a failing grade because while technically doing the job it's by no means something that should be considered to be done.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now