create table tb3(
学号 varchar(10),
课程 varchar(10)
)
insert into tb3 values('001','语文')
insert into tb3 values('001','数学')
insert into tb3 values('001','英语')
insert into tb3 values('001','计算机')
insert into tb3 values('002','语文')
insert into tb3 values('002','数学')
insert into tb3 values('002','计算机')
insert into tb3 values('003','语文')
insert into tb3 values('003','数学')
insert into tb3 values('003','英语')
insert into tb3 values('004','语文')
insert into tb3 values('004','英语')
insert into tb3 values('005','语文')
insert into tb3 values('005','数学')
insert into tb3 values('005','英语')
insert into tb3 values('005','计算机')
select 学号, num
from
(
select 学号, count(课程) as num from tb3 group by 学号
)a
where num =
(
select count(distinct 课程) from tb3
)