create table tabl(类型 varchar(10),客户 varchar(10)) insert into tabl select '普通','张三' union all select '普通','李四' union all select 'vip','王五' union all select 'vip','赵六'select id=identity(int,1,1),* into #t from tabl select case when 类型=(select top 1 类型 from #t a where a.id<#t.id order by a.id desc) then '' else 类型 end '类型',客户 from #t drop table #t /* 类型 客户 ---------- ---------- 普通 张三 李四 vip 王五 赵六(所影响的行数为 4 行) */
insert into tabl
select '普通','张三'
union all select '普通','李四'
union all select 'vip','王五'
union all select 'vip','赵六'select id=identity(int,1,1),* into #t from tabl
select case when 类型=(select top 1 类型 from #t a where a.id<#t.id order by a.id desc) then '' else 类型 end '类型',客户
from #t
drop table #t
/*
类型 客户
---------- ----------
普通 张三
李四
vip 王五
赵六(所影响的行数为 4 行)
*/