17,377
社区成员
发帖
与我相关
我的任务
分享
with temp as(
select '10001' sno,'001' bno,50 score from dual
union all
select '10002' sno,'001' bno,60 score from dual
union all
select '10003' sno,'002' bno,70 score from dual
)
select bno,max(totalsum),max(avgsum) from (
select bno,null totalsum,count(sno) avgsum from temp where score >=60 group by bno
union all
select bno,count(sno) totalsum,null avgsum from temp group by bno
)group by bno