27,579
社区成员
发帖
与我相关
我的任务
分享
select a.学号 from (select 学号,count(*) 次数 from tab1 group by 学号) a,
(select 学号,min(次数) 次数 from
(select 学号,count(*) 次数 from tab1 group by 学号 ) a
group by 学号) b
a.次数=b.次数
select top 1 stu_id from
(
select stu_id,cnt=count(distinct(cour_id))
from tb
group by stu_id
)t
order by cnt
select top 1 stu_id from tb
group by stu_id
order by count(distinct cour_id)
--try
select * from (
select 学号,count(课程号) total
from tab1
group by 学号)a
where total =(select min(total) from (select 学号,count(课程号) total
from tab1
group by 学号)b)
select top 1 *
from
(select 学号,count(课程号) total
from tab1
group by 学号
)t
order by total
select top 1 stu_id from tb group by stu_id order by count(*)