+ 2
SQL: Order and Limit
I have a Database with 10 Employees. Starting from 1 to 10. When I use this code: SELECT EmployeeID FROM Employees ORDER BY EmployeeID LIMIT 0,3; I get IDs 1,2,3 But when I add DESC after ORDER BY I get 10,9,8 is there any way I can get it to display 3,2,1?
3 Respostas
+ 2
SELECT EmployeeID
FROM Employees
WHERE EmployeeID < 4
ORDER BY EmployeeID DESC;
+ 6
WHERE EmployeeID <= 3
+ 1
Thanks.
The other answer I have is:
SELECT EmployeeID
FROM (
SELECT EmployeeID
FROM Employees
ORDER BY EmployeeID
LIMIT 0,3
)
ORDER BY EmployeeID DESC;