日期:2014-05-18 浏览次数:20665 次
-->TravyLee生成测试数据:[test]
if object_id('[test]') is not null drop table [test]
create table [test]([type] varchar(3),[Name] varchar(2))
insert [test]
select 'A类','A1' union all
select 'B类','B1' union all
select 'A类','A2' union all
select 'B类','B2'
select distinct [type] as [type],[Name]='' from test
union all
select * from test
order by [type],[Name]
/*
type Name
A类
A类 A1
A类 A2
B类
B类 B1
B类 B2
*/
------解决方案--------------------
楼上正解,沙发。