这样的SQL语句有人会吗?请高手帮忙下!
8880009196335745583154687502008-09-19 21:17:11.547NULL
8880009196335745584001562502008-09-19 21:17:20.0172008-09-19 21:17:20.017
8880009196335745601378125002008-09-19 21:20:13.7802008-09-19 21:20:13.780
8880009196335745602137500002008-09-19 21:20:21.3772008-09-19 21:20:21.377
8880009196335745604859375002008-09-19 21:20:48.5932008-09-19 21:20:48.593
我想要的效果是
8880009196335745583154687502008-09-19 21:17:11.547NULL
9196335745584001562502008-09-19 21:17:20.0172008-09-19 21:17:20.017
9196335745601378125002008-09-19 21:20:13.7802008-09-19 21:20:13.780
9196335745602137500002008-09-19 21:20:21.3772008-09-19 21:20:21.377
9196335745604859375002008-09-19 21:20:48.5932008-09-19 21:20:48.593
可以实现吗
[解决办法]
- SQL code
--> Test Data: @Tdeclare @T table (id int identity(1,1), [c1] int,[c2] numeric(21,0),[c3] datetime,[c4] datetime)insert into @Tselect 888000,919633574558315468750,'2008-09-19 21:17:11.547',null union allselect 888000,919633574558400156250,'2008-09-19 21:17:20.017','2008-09-19 21:17:20.017' union allselect 888000,919633574560137812500,'2008-09-19 21:20:13.780','2008-09-19 21:20:13.780' union allselect 888000,919633574560213750000,'2008-09-19 21:20:21.377','2008-09-19 21:20:21.377' union allselect 888000,919633574560485937500,'2008-09-19 21:20:48.593','2008-09-19 21:20:48.593'select * from @T--Codeselect 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*/