Home > database >  First rows for selected cid then show the others rows
First rows for selected cid then show the others rows

Time:10-08

I have orders table like this:

OID CID ODATE 
1    1  01/01/21
2    2  01/02/21 
3    2  20/01/21 
4.   3. 20/01/21 
5.   4. 20/01/21 

I want to see all the orders of cid 2 first then all the others thanks ...

CodePudding user response:

You may order using a CASE expression:

SELECT *
FROM yourTable
ORDER BY CASE CID WHEN 2 THEN 1 ELSE 2 END;

You may also add more sorting levels after the above CASE expression.

  • Related