开发者

How to do a special order clause in postgresql?

开发者 https://www.devze.com 2023-03-20 12:05 出处:网络
I have a result set like this: a b c This result will be fixed each time. What I need to do is order the rows like this a c b.

I have a result set like this: a b c

This result will be fixed each time. What I need to do is order the rows like this a c b. How can I开发者_开发百科 do that ?


SELECT  value
FROM    mytable
ORDER BY
        CASE value WHEN 'a' THEN 1 WHEN 'c' THEN 2 WHEN 'b' THEN 3 END
0

精彩评论

暂无评论...
验证码 换一张
取 消