高手请进!sql server在查询出的结果增加空白行!
ID相同的为一组,每组不足三行的补足三行,保证每组都能被三整除!!
实列如下!
id name
1 aa
1 a
1 aa
2 aq
2 aq
3 a
3 a
3 v
3 d
4 c
要的结果
id name
1 aa
1 a
1 aa
2 aq
2 aq
null null
3 a
3 a
3 v
3 d
null null
null null
4 c
null null
null null
create table cs (id char (2),name char (10))
insert into cs
select'1' , 'aa'
union all
select'1' , 'a'
union all
select'1' , 'aa'
union all
select'2' , 'aq'
union all
select'2' , 'aq'
union all
select'3' , 'a'
union all
select'3' , 'a'
union all
select'3' , 'v'
union all
select'3' , 'd'
union all
select'4' , 'c'
------解决方案--------------------create table cs (id char (2),name char (10))
insert into cs
select'1' , 'aa'
union all
select'1' , 'a'
union all
select'1' , 'aa'
union all
select'2' , 'aq'
union all