I have a table with incremented id from 1,2,3…and so on. What i want is just to sort the data in descending order on the basis of field ‘id’ except first two rows. I tried using below query:-
SELECT * FROM categories ORDER BY CASE WHEN id<3 THEN 0 ELSE id END DESC
It give me the result like
id name
5 Meal
4 Apparel
3 Electronics
1 Sports
2 Lifestyle
But output should come like
id name
1 Sports
2 Lifestyle
5 Meal
4 Apparel
3 Electronics
Is there any way to achieve this by using such query?
Try this:
Edit:
A better solution which does not require hard coding
10000: