我的表products
列price
。
它有行值:
2
0
4
5
0
3
1
我应该使用select
的哪些参数来获得这样的结果:
1
2
3
4
5
0
0
答案 0 :(得分:4)
你可以先订购0&然后休息
SELECT * FROM <table> ORDER BY CASE WHEN price = 0 THEN 1 ELSE 0 END,price
答案 1 :(得分:3)
select * from products
order by price = 0, price
答案 2 :(得分:0)
试试吧
SELECT *
FROM test
ORDER BY IF(price=0,999999999,price)
SQL小提琴 - http://sqlfiddle.com/#!9/98f02/2