學生(學號,姓名,年齡,性別)STUDENT (SNO, SNAME, AGE, SEX)
選課(學號,課號,成績) GRADE (SNO, CNO, SCORE)
課程(課號,課名,老師) COURSE (CNO, CNAME, TEACHER)
試用SQL完成下列查詢功能:
1、檢索 Wang 同學不學的課程的課程號
2、檢索全部學生都選修的課程的課程號與課程名
3、檢索選修少于三門課程且沒有選修LIU老師所授課程的學生姓名打標識
uj5u.com熱心網友回復:
樓主哪個題目不會?uj5u.com熱心網友回復:
一看就是老師給的題目呀,你都沒資料咋寫SQL,而且最好是給你思路 然后自己寫撒
uj5u.com熱心網友回復:
1、select cno from course where cno not in (select a.cno from grade a,student b where a.sno = b.sno and b.sname = 'wang')2、select cno,cname from course where cno in
(
select a.cno from
(select cno,count(distinct sno) as amount2 from grade group by cno) a,
(select count(distinct sno) as amount1 from grade) b
where a.amount2 = b.amount1
)
3、select sname from student where sno in
(
select a.sno from
(select sno,count(distinct cno) from grade group by sno having count(distinct cno) < 3) a,
(select distinct sno from grade where cno not in (select cno from course where teacher = 'liu')) b
where a.cno = b.cno
)
uj5u.com熱心網友回復:
第二道題有些難度轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/49711.html
標籤:基礎和管理
