帮忙用SQL(oracle)实现个查询(今天的一个面试题),谢谢!

2025-03-23 19:27:08
推荐回答(1个)
回答1:

select t_name from t,
(select t.t_id t_id,count(*) count from t,s,c where t.t_id=c.t_id and s.s_id=c.s_id and c.cname='大班' group by t.t_id) a,
(select t.t_id t_id,count(*) count from t,s,c where t.t_id=c.t_id and s.s_id=c.s_id and c.cname='小班' group by t.t_id) b
where t.t_id=a.t_id
and t.t_id=b.t_id
and a.count>b.count