问一条类似行列转换的sql语句

[复制链接]
查看11 | 回复2 | 2010-10-8 09:31:22 | 显示全部楼层 |阅读模式
002
003
004
005
006
007 转成002,003,004

005,006,007
左边的是 select a from test是按列显示
有没有办法搞成,一行显示三个,这样拆分,谢谢。
回复

使用道具 举报

千问 | 2010-10-8 09:31:22 | 显示全部楼层
现在,我改到这样
--生成带行号的数据临时表#temptable
SELECT no = IDENTITY (int, 1, 1), *
NTO #temptable
FROM clientsect where sectstate = 'hold'
--下面的是得到第一列数,第二列数据,现在问题是不知道怎么合,搞不好就是笛卡乐积
select clientid from #temptable where no%7=1
select clientid from #temptable where no%7=2
select clientid from #temptable where no%7=3
select clientid from #temptable where no%7=4
select clientid from #temptable where no%7=5
select clientid from #temptable where no%7=6
select clientid from #temptable where no%7=7
请大家帮我一下,谢谢。
回复

使用道具 举报

千问 | 2010-10-8 09:31:22 | 显示全部楼层
学习中...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行