select identity(int,0,1) flag,* into #临时表 from 你的表select
max(case when flag%4=0 then name end) 列1,
max(case when flag%4=1 then name end) 列2,
max(case when flag%4=2 then name end) 列3,
max(case when flag%4=3 then name end) 列4
from #临时表 group by flag/4go
drop table #临时表
max(case when flag%4=0 then name end) 列1,
max(case when flag%4=1 then name end) 列2,
max(case when flag%4=2 then name end) 列3,
max(case when flag%4=3 then name end) 列4
from #临时表 group by flag/4go
drop table #临时表
解决方案 »
- SQL2005清除日志的问题
- dataset, sqldataadapter 和 datagridview的问题
- 请教一个问题,系统表里有没有一个记录数据库里所有表名称的表呀
- MySql所谓的全连接怎么实现?
- sqlserver2005传输错误
- 关于数据库存储过程执行超时的问题?请各位给点意见。。。
- 请问如何强制性恢复数据库
- 求一条很难的sql语句,谢谢!
- 触发器问题!!!
- 那我现在一个10万字的字符串,如何用一个变量代替它?
- 如何从数据库写一张表到数据包,并从数据包中读出这张表?急!
- 请问一下,如何用alter table...add constrarnt...primary key,来加主键约束
----------- --------------------
1 aaa
2 bbb
3 ccc
4 ddd
5 eee
6 fff
7 ggg
8 hhh(所影响的行数为 8 行)列1 列2 列3 列4
-------------------- -------------------- -------------------- --------------------
NULL aaa bbb ccc
ddd eee fff ggg
hhh NULL NULL NULL(所影响的行数为 3 行)警告: 聚合或其它 SET 操作消除了空值。
------------------------
大力的没有错。你的MeId 是重1开始的,你看看大力的identity(int,0,1)是重0开始的。如果按照你的写法,应该用MeId-1代替才可以。