一个比较难的SQL语句,高手来.
if exists(select name from sysobjects where xtype= 'U ' and name= 'tbl1 ')
drop table tbl1
go
create table tbl1 ( c1 nvarchar(10),c2 nvarchar(10),c3 nvarchar(10),c4 nvarchar(10),c5 nvarchar(10))
go
insert tbl1
select '1 ', 'a ', 'b ', 'c ', 'a '
union all select '2 ', 'a ', 'b ', 'c ', 'b '
union all select '3 ', 'a ', 'b ', 'c ', 'c '
union all select '4 ', 'a ', 'b ', 'c ', 'd '
union all select '5 ', 'a ', 'b ', 'c ', 'e '
union all select ' ', 'a ', 'b ', 'c ', 'f '
union all select ' ', 'a ', 'b ', 'c ', 'g '
union all select ' ', 'a ', 'b ', 'c ', 'h '
要求得到的结果是:
C1 C2 C3 C4 C5
1 a b c a
2 a b c b
3 a b c c
4 a b c d
5 a b c e
7 a b c f
8 a b c g
9 a b c h
要求如下:用一个update语句实现,根据C5列可以知道后三列的顺序,解决了给加分.
------解决方案--------------------7 8 9
为什么不是
6 7 8