create table tablename(
序号 int ,
姓名 varchar(80),
日期 varchar(50)
)
go
insert tablename select 1,'张三','20051102'
union select 2,'张三','20051104'
union select 3,'张三','20051105'
union select 4,'张三','20051107'
union select 5,'李四','20051102'
union select 6,'李四','20051111'
union select 7,'王五','20051116'
union select 8,'王五','20051109'
union select 9,'张三','20051122'go
---查询
select * from tablename
where 序号 in(
select 序号 from tablename a
where not exists(
select * from tablename b
where b.序号=a.序号-1 and b.姓名=a.姓名
))drop table tablename
经典sql语句
最新推荐文章于 2024-04-23 15:49:27 发布