Reputation: 21509
I need to use an ORDER BY
on a table but keep some special rows on top.
The rows that have name='developer'
for example.
Upvotes: 2
Views: 227
Reputation: 127556
You could also do the ORDER BY without the usage of a CASE:
ORDER BY
name = 'developer' DESC,
name ASC;
Upvotes: 3
Reputation: 26118
Something like this might work for you.
SELECT * FROM table ORDER BY CASE WHEN name = 'developer' THEN 0 ELSE 1 END, name
Upvotes: 1
Reputation: 169524
ORDER BY CASE WHEN name = 'developer' THEN '0' ELSE name END
Upvotes: 5