概述
21.查询男生、女生人数
select f.c,m.c
from
(
select count(sid) c from student where ssex='男'
) f
join
(
select count(sid) c from student where ssex='女'
) m;
select * from student where sname like '%风%';
select sname,ssex,count(1)
from student
group by sname,ssex
having count(1)>1;
select sname from student where substring(sage,0,4)='1990';
select cid c,round(avg(score),1) a from sc group by cid order by a,c desc;
26.查询不及格的课程,并按课程号从大到小排列
select cid c,score from sc where score<60 order by c desc;
select s.sid,s.cid,s.score
from
(
select sid,cid,score,row_number()over(partition by cid order by score desc) rank from sc
) s
where s.rank<=2;
select cid,count(sid) c from sc group by cid having count(sid)>5 order by c desc,cid;
select sid,count(cid) c from sc group by sid having c>=2;
30.查询选修了全部课程的学生信息
select student.sid,student.sname
from
student
join
(
select s.sid
from
(
select count(cid) c from course
) cou
join
(
select sid,count(cid) c from sc group by sid
) s
on cou.c=s.c
) o
on student.sid=o.sid;
最后
以上就是成就书本为你收集整理的hive学习之经典sql50题 hive版(四)的全部内容,希望文章能够帮你解决hive学习之经典sql50题 hive版(四)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复