-2

I have a result of SQL like this

status || value 
 green     3
 blue      39
 pink      2
 black     300

I want to change the row of blue and pink

I want to sort like this from green, pink, blue, and black for that row and value also is that possible to the condition that row to be by own?

so the result will be like this

status || value 
 green     3
 pink      2
 blue      39
 black     300
temps hd
  • 71
  • 1
  • 10

2 Answers2

0

use case when

select status,value from table
order by case status when 'green' then 1
              when 'pink' then 2
              when 'blue' then 3
              when 'black' then 4 end 
Zaynul Abadin Tuhin
  • 31,407
  • 5
  • 33
  • 63
0

You can try using field()

SELECT status,value
FROM tablename
ORDER BY FIELD(status, "green", "pink", "blue","black")
Fahmi
  • 37,315
  • 5
  • 22
  • 31