数据库第四章实验
1.
SELECT Sno, Sname FROM Student
2.
SELECT Sname,Sno,Sdept FROM Student
3.
SELECT * FROM Student
4.
SELECT Sname, 2022 - Sage FROM Student
5.
SELECT Sname, '出生年份', 2022 - Sage FROM Student
6.
SELECT Sno FROM SC
7.
SELECT Sname FROM Student WHERE Sdept = '计算机系'
8.
SELECT Sname , Sage FROM Student WHERE Sage < 20
9.
SELECT DISTINCT Sno FROM SC WHERE Grade < 60
10.
SELECT Sname,Sdept,Sage FROM Student
WHERE Sage BETWEEN 20 AND 23
11.
SELECT Sname,Sdept,Sage FROM Student
WHERE Sage NOT BETWEEN 20 AND 23
12.
SELECT Sname,Ssex FROM Student
WHERE Sdept IN ('信息系','数学系','计算机系')
13.
SELECT Sname,Ssex FROM Student
WHERE Sdept NOT IN ('信息系','数学系','计算机系')
14.
SELECT * FROM Student WHERE Sname LIKE '张%'
15.
SELECT * FROM Student WHERE Sname LIKE '[张李刘]%'
16.
SELECT Sname,Sno FROM Student WHERE Sname LIKE '_[小大]%'
17.
SELECT Sname FROM Student WHERE Sname NOT LIKE '[王张]%'
18.
SELECT Sname FROM Student WHERE Sname LIKE '王_'
19.
SELECT Sname FROM Student WHERE Sname LIKE '王__'
20.
SELECT Sno, Cno FROM SC WHERE GRADE IS NULL
21.
SELECT Sno, Cno FROM SC WHERE GRADE IS NOT NULL
22.
SELECT Sname,Sage FROM Student
WHERE Sdept = '计算机系' AND Sage < 20
23.
SELECT Sname, Sdept,Sage FROM Student
WHERE (Sdept = '计算机系' OR Sdept = '信息系')
AND Sage >= 20
24.
SELECT * FROM Student ORDER BY Sage ASC
25.
SELECT Sno,Grade FROM SC
WHERE Cno = 'c002' ORDER BY Grade DESC
26.
SELECT * FROM Student ORDER BY Sdept, Sage DESC
27.
SELECT COUNT(*) AS 学生人数 FROM Student
28.
SELECT COUNT(DISTINCT Sno) 选课人数 FROM SC
29.
SELECT COUNT(*) AS 选课人数, SUM(Grade) AS 总成绩
FROM SC WHERE Sno = '1512101'
30.
SELECT AVG(Grade) AS 平均成绩 FROM SC WHERE Cno = 'c001'
31.
SELECT MAX(Grade) AS 最高分, MIN(Grade) AS 最低分 
FROM SC WHERE Cno = 'c001'
32.
SELECT COUNT(*) AS 选课门数, COUNT(Grade) AS 考试门数,
MAX(Grade) AS 最高分, MIN(Grade) AS 最低分,
AVG(Grade) AS 平均分
FROM SC WHERE Sno = '1512101'
33.
SELECT Cno AS 课程号,COUNT(Sno) AS 选课人数
FROM SC GROUP BY Cno
34.
SELECT Sno 学号,COUNT(*) 选课门数,AVG(Grade) 平均成绩
FROM SC
GROUP BY Sno
35.
SELECT Sdept, COUNT(*) AS 学生人数, AVG(Sage) AS 平均年龄
FROM Student GROUP BY Sdept
36.
SELECT Sdept, Count(*) 女生人数 FROM Student
WHERE Ssex = '女'
GROUP BY Sdept
37.
SELECT Sdept, Ssex, Count(*) 人数, MAX(Sage) 最大年龄
FROM Student
GROUP BY Sdept, Ssex
ORDER BY Sdept
38.
SELECT Sno,COUNT(*) 选课门数,AVG(Grade) 平均人数 FROM SC
GROUP BY Sno
HAVING COUNT(*) > 3
39.
SELECT Sno,COUNT(*) 选课门数,AVG(Grade) 平均人数 
FROM SC
GROUP BY Sno
HAVING AVG(Grade) >= 80
40.
SELECT Sdept, COUNT(*) 人数
FROM Student
WHERE Ssex = '男'
GROUP BY Sdept
HAVING COUNT(*) >= 2
41.
SELECT * FROM Student INNER JOIN SC
ON Student.Sno = SC.Sno
42.
SELECT Student.Sno,Sname,Ssex,Sage,Sdept,Cno,Grade
FROM Student JOIN SC ON Student.Sno = SC.Sno
43.
SELECT Student.Sno,Sname,Cno,Grade FROM Student JOIN SC 
ON Student.Sno = SC.Sno
WHERE Sdept = '计算机系'
44.
SELECT Sname,Cname,Grade 
FROM Student JOIN SC ON Student.Sno = SC.Sno
JOIN Course ON Course.Cno = SC.Cno
WHERE Sdept = '计算机系'
AND Cname = '计算机文化学'
45.
SELECT Sname,Sdept FROM Student 
JOIN SC ON Student.Sno = SC.Sno
JOIN Course ON Course.Cno = SC.Cno
WHERE Cname = 'Java'
46.
SELECT Sdept, AVG(Grade) as AverageGrade
FROM Student JOIN SC ON Student.Sno = SC.Sno
GROUP BY Sdept
47.
SELECT Cno, COUNT(*) AS Total, AVG(Grade) as AvgGrade,
MAX(Grade) as MaxGrade, MIN(Grade) as MinGrade
FROM Student JOIN SC ON Student.Sno = SC.Sno
WHERE Sdept = '计算机系'
GROUP BY Cno
48.
SELECT S2.Sname,S2.Sdept FROM Student S1 JOIN Student S2
ON S1.Sdept = S2.Sdept
WHERE S1.Sname = '刘晨'
AND S2.Sname != '刘晨'
49.
SELECT C1.Cname,C1.Credit
FROM Course C1 JOIN Course C2
ON C1.Credit = C2.Credit
WHERE C2.Cname = '数据结构'
50.
SELECT Student.Sno, Sname, Cno, Grade
FROM Student LEFT OUTER JOIN SC
ON Student.Sno = SC.Sno
51.
SELECT Cname FROM Course LEFT JOIN SC
ON Course.Cno = SC.Cno
WHERE SC.Cno IS NULL
52.
SELECT TOP 3 Sname,Sage,Sdept
FROM Student
ORDER BY Sage DESC
53.
SELECT TOP 3 WITH TIES Sname,Sdept,Grade
FROM Student JOIN SC ON Student.Sno = SC.Sno
JOIN Course ON Course.Cno = SC.Cno
WHERE Cname = 'Java'
ORDER BY GRADE DESC
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇