[英]SQL Server : order by - column equal to zero or larger
I would like to order a result list by a computed float column A and then a column B.我想通过计算的浮点 A 列和 B 列对结果列表进行排序。
I would like to first get all rows where the computed field A is larger than zero, then ordered by B. After that all the rows which are zero then ordered by B.我想首先获取计算字段 A 大于零的所有行,然后按 B 排序。之后所有为零的行然后按 B 排序。
select * from your_table
order by case when colA > 0 then 1
when colA = 0 then 2
when colA < 0 then 3
end,
colB
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.