-- 把'小明'排在第一位
select *
from CUSTOMER_INFO T
where T.CUSTOMER_ID = 12204
order by case when name= '小明' then 0 else 1 end asc
本文介绍了一种使用SQL进行特定条件排序的方法,通过CASE WHEN语句实现对指定名称为'小明'的数据优先显示。
-- 把'小明'排在第一位
select *
from CUSTOMER_INFO T
where T.CUSTOMER_ID = 12204
order by case when name= '小明' then 0 else 1 end asc
1046
8557

被折叠的 条评论
为什么被折叠?