这是我桌子的示例风景。首先我必须找到,按 ITime asc 排序,但是如果有任何记录在 ITime 中相同,那么记录顺序将是“通过->失败->撤回”。请检查下面的临时表。
if object_id('tempdb.dbo.#temp321','U') is not null
drop table tempdb.dbo.#temp321
create table #temp321(
id int,
uname varchar(50),
ITime datetime,
Result varchar(10)
)
INSERT into #temp321 values('1','a','2012-11-12 13:12:28.103','pass')
INSERT into #temp321 values('2','b','2012-11-12 13:12:28.103','fail')
INSERT into #temp321 values('3','c','2012-11-12 12:58:30.000','pass')
INSERT into #temp321 values('4','d','2012-11-12 13:12:28.103','withdrow')
INSERT into #temp321 values('5','e','2012-11-12 12:58:41.360','withdraw')
INSERT into #temp321 values('6','f','2012-11-12 13:12:28.103','pass')
INSERT into #temp321 values('7','g','2012-11-12 13:12:28.103','fail')
select ID from #temp321 ORDER BY ITime ASC
drop table #temp321
Expected outcomes ID value : 3,5,1,6,2,7,4
我怎么做?提前致谢。