Hi All,
My query is: select name from customer where id (1, 5, 3, 2);
The result I am getting is descending order of id like this:
1 a
2 b
3 c
5 d
How can I get order by my specific values in id list like this:
1 a
5 d
3 c
2 b
Thanks!
Darma
Loading
VulpesPosted Aug 20, 2014, 4:25 AM
VulpesPosted Aug 20, 2014, 5:01 AM
It's a pity that it's not available in SQL Server as well.
darma tejaPosted Aug 20, 2014, 4:52 AM
@Ankur jain: It is giving me error at field (is field not may work for SQL 2005?)
Ankur JainPosted Aug 20, 2014, 4:19 AM
try like this..
SELECT name FROM customer ORDER BY FIELD('id',1,5,3,2)
please mark it as answer if its helpful...