这是我写的语句,大神有时间帮看下:
select * from TB t where exists
(select * from TB where 班级<>t.班级 and 姓名=t.姓名 and 年龄=t.年龄 and 国籍=t.国籍)
and t.班级 in('01','02')
select * from TB t where exists
(select * from TB where 班级<>t.班级 and 姓名=t.姓名 and 年龄=t.年龄 and 国籍=t.国籍)
and t.班级 in('01','02')
SELECT * FROM(
select T.*,COUNT(DISTINCT 班级)OVER(PARTITION BY 姓名,年龄,国籍) S from TB T
WHERE 班级 in('01','02')
)WHERE S>1