日期:2014-05-18 浏览次数:20459 次
--> Test Data: @T declare @T table (id int identity(1,1), [c1] int,[c2] numeric(21,0),[c3] datetime,[c4] datetime) insert into @T select 888000,919633574558315468750,'2008-09-19 21:17:11.547',null union all select 888000,919633574558400156250,'2008-09-19 21:17:20.017','2008-09-19 21:17:20.017' union all select 888000,919633574560137812500,'2008-09-19 21:20:13.780','2008-09-19 21:20:13.780' union all select 888000,919633574560213750000,'2008-09-19 21:20:21.377','2008-09-19 21:20:21.377' union all select 888000,919633574560485937500,'2008-09-19 21:20:48.593','2008-09-19 21:20:48.593' select * from @T --Code select c1= case when exists(select 1 from @T where c1 = a.c1 and id < a.id) then '' else ltrim(c1) end, c2,c3,c4 from @T a --Drop --Result /* c1 c2 c3 c4 ------------ --------------------------------------- ----------------------- ----------------------- 888000 919633574558315468750 2008-09-19 21:17:11.547 NULL 919633574558400156250 2008-09-19 21:17:20.017 2008-09-19 21:17:20.017 919633574560137812500 2008-09-19 21:20:13.780 2008-09-19 21:20:13.780 919633574560213750000 2008-09-19 21:20:21.377 2008-09-19 21:20:21.377 919633574560485937500 2008-09-19 21:20:48.593 2008-09-19 21:20:48.593 */