SELECT * FROM emm_task.tbl_scm_passenger ORDER by CASE WHEN id IN (53213970,53213971,53213972,53213973,53213974,53213975,53213976,53213977,53213978,53213979,53213980,53213981,53213982,53213983,53213984,53213985,53213986,53213987,53213988,53213989) THEN 0 ELSE 1 END, CASE WHEN id IN (53213970,53213971,53213972,53213973,53213974,53213975,53213976,53213977,53213978,53213979,53213980,53213981,53213982,53213983,53213984,53213985,53213986,53213987,53213988,53213989) then phone end asc修改这段sql排序空值在最后
时间: 2023-08-01 19:09:14 浏览: 111
EMM2017_Sph_Windows.zip_amma3_emm2017_地磁_地磁场_地磁坐标
5星 · 资源好评率100%
您可以使用以下SQL语句来实现您的需求:
```
SELECT * FROM emm_task.tbl_scm_passenger
ORDER BY
CASE
WHEN id IN (53213970,53213971,53213972,53213973,53213974,53213975,53213976,53213977,53213978,53213979,53213980,53213981,53213982,53213983,53213984,53213985,53213986,53213987,53213988,53213989)
THEN 0
ELSE 1
END,
phone IS NULL,
phone ASC;
```
这个SQL语句中使用了两个排序条件:第一个是将ID为指定值的行排在前面,其余行排在后面;第二个是将`phone`字段为NULL的行排在后面,非NULL值的行按升序排列。
阅读全文