一般情况之下,我们可以使用order by …asc或desc来做查询排序。如:
select * from [dbo].[salesperformance] order by [salesman] asc go
如果需要求某一些值先排在前面,其余的数据再按规则排序,如salesman的值‘s0008’,‘s0032’,‘s0022’排在前3位:
select * from [dbo].[salesperformance] order by case when [salesman] = 's0008' then '1' when [salesman] = 's0032' then '2' when [salesman] = 's0022' then '3' else [salesman] end asc