我有一个带有列的表
[ID] AS bigint
[CompanyID] AS bigint
[Name] AS nvarchar(50)
[Position] AS nvarchar(15)
组合框中的位置不变,价值观是总统,副总统,秘书等。我需要对数据进行排序,因为第一个是总统第二个是副总裁......
答案 0 :(得分:0)
order by ID
也许?
除非您在查询中有另一个可用于order by
的数据列。这听起来非常具体,因此您需要在数据中使用某些内容来订购它们。
答案 1 :(得分:0)
检查一下。用例何时实现它。
Create table #Employee(
ID bigint,
Name nvarchar(50),
Position nvarchar(15)
)
insert into #Employee values (031,'AAA','Secretary')
insert into #Employee values(781,'ZZZ','Secretary')
insert into #Employee values(166,'PPP','President')
insert into #Employee values(561,'BBB','Vice President')
insert into #Employee values(441,'KKK','Secretary')
insert into #Employee values(124,'DDD','Secretary')
insert into #Employee values(100,'ZZZ','Vice President')
select *,CASE
WHEN Position='President' THEN 1
WHEN Position='Vice President' THEN 2
WHEN Position='Secretary' THEN 3
END AS [PositionOrder] from #Employee
order by [PositionOrder]
drop table #Employee