假设数据表定义如下:
学生表 student(sid,sname,sex,age,native,tel, dept)学号,姓名,性别,年龄,籍贯,电话,系部
课程表 kc(cid, cname)课程号,课程名称
成绩表 cj(sid,cid,score)学号,课程号,成绩
SQL语句如下:
1
SELECT
FROM student
WHERE tel IS NULL
2
SELECT
FROM student
WHERE age IS NOT NULL
3
SELECT
FROM student
WHERE (native LIKE '四川省%' OR native LIKE '云南省%') AND age > 20
4
SELECT '人数' = COUNT()
FROM student
5
SELECT '人数' = COUNT()
FROM student
WHERE native LIKE '四川省%'
6
SELECT '人数' = COUNT()
FROM student
WHERE sex = '男'
7
SELECT sex, '人数' = COUNT()
FROM student
GROUP BY sex
8
SELECT native, '人数' = COUNT()
FROM student
GROUP BY native
9
SELECT dept, COUNT()
FROM student
GROUP BY dept
HAVING COUNT() > 4
10
SELECT '最高分' = MAX(score),
'最低分' = MIN(score),
'平均分' = AVG(score),
'总分' = SUM(score)
FROM cj
11
SELECT '最高分' = MAX(score),
'最低分' = MIN(score),
'平均分' = AVG(score),
'总分' = SUM(score)
FROM cj
WHERE sid = 104
12
SELECT cid, '选修人数' = COUNT()
FROM cj
GROUP BY cid
13
SELECT '总成绩' = SUM(score),
'平均分' = AVG(score),
'最高分' = MAX(score),
'最低分' = MIN(score),
'选课总门数' = COUNT()
FROM cj
GROUP BY sid
14
SELECT '总成绩' = SUM(score),
'平均分' = AVG(score),
'最高分' = MAX(score),
'最低分' = MIN(score),
'选课总门数' = COUNT()
FROM cj
GROUP BY sid
HAVING COUNT() >= 2
以上就是关于数据库查询语句,谁会,谢谢全部的内容,包括:数据库查询语句,谁会,谢谢、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)