-1

I want to print the trending row first and then New and then all other row from the table "employee".

Also i want limit the number of row and in descending order

I was trying this

SELECT * FROM (SELECT * FROM employee LIMIT 7) sub ORDER BY id DESC

TU

Expected Result

enter image description here

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786

1 Answers1

2

You may try ordering with a CASE expression:

SELECT id, Name, Status
FROM employee
ORDER BY
    CASE Status WHEN 'Trending' THEN 1
                WHEN 'NEW' THEN 2
                ELSE 3 END,
    id DESC
LIMIT 7;
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360