本题目要求编写SQL语句, 检索``sc```表中成绩不及格的学生学号、课号和成绩,并按成绩降序排列。 提示:请使用SELECT语句作答。 表结构: 请在这里写定义表结构的SQL语句。例如: CREATE TABLE sc ( sno char(7) , cno char(7) , score decimal(4,1), point decimal(2,1), PRIMARY KEY (sno,cno) ) ; 表样例 请在这里给出上述表结构对应的表样例。例如 sc表: sno cno score point 1711202 0000011 43.0 0.0 1711202 0000027 80.0 1.0 1911201 0000027 54.0 1.0 1911201 0000052 71.0 2.0 输出样例: 请在这里给出输出样例。例如: sno cno score 1911201 0000027 54.0 1711202 0000011 43.0
时间: 2024-02-26 08:55:16 浏览: 309
CREATE TABLE sc (
sno char(7) ,
cno char(7) ,
score decimal(4,1),
point decimal(2,1),
PRIMARY KEY (sno,cno)
);
SELECT sno, cno, score
FROM sc
WHERE score < 60
ORDER BY score DESC;
输出样例:
sno cno score
1911201 0000027 54.0
1711202 0000011 43.0
相关问题
要求编写SQL语句, 检索``sc```表中成绩不及格的学生学号、课号和成绩,并按成绩降序排列
好的,以下是您需要的SQL语句:
```
SELECT sno, cno, score
FROM sc
WHERE score < 60
ORDER BY score DESC;
```
这条语句会检索``sc``表中成绩不及格的学生学号、课号和成绩,并按成绩从高到低排序。
根据上面的对话检索“程军”老师所授课程的课程号和课程名。 (3)检索年龄大于19岁男学生的学号和姓名。 (4)检索“李勇”同学不学课程的课程号。 (5)检索至少选修两门课程的学生学号。 (6)检索选修课程号为1和2的学生学号。 (7)检索至少选修“程军”老师所授全部课程的学生姓名。 (8)检索选修课程包含学号为201215122的学生所修课程的学生学号。 (9)检索全部学生都选修的课程的课程号和课程名。 (10)检索选修全部课程的学生姓名。 (11)查询所在系是CS系的学生选修的课程的课程名和学分,结果按课程名降序排序。 (12)检索“数据库”课程成绩高于90分的所有学生的学号、姓名和分数. (13)查询男生和女生选修课程的平均成绩。 (14)检索没有选课的学生的学号和姓名。 (15)检索没有任何一门课程成绩不及格的学生的信息,包括学号、姓名
很抱歉,作为语言模型,我不能直接连接数据库进行数据检索。但是,我可以提供一些 SQL 查询语句的示例,您可以根据这些示例进行相应的查询操作:
1. 检索“程军”老师所授课程的课程号和课程名:
```
SELECT Cno, Cname
FROM Course
WHERE Cpno IN (SELECT Cno FROM Course WHERE Cname = '程军');
```
2. 检索年龄大于19岁男学生的学号和姓名:
```
SELECT Sno, Sname
FROM Student
WHERE Ssex = '男' AND Sage > 19;
```
3. 检索“李勇”同学不学课程的课程号:
```
SELECT Cno
FROM Course
WHERE Cno NOT IN (SELECT Cno FROM SC WHERE Sno = (SELECT Sno FROM Student WHERE Sname = '李勇'));
```
4. 检索至少选修两门课程的学生学号:
```
SELECT Sno
FROM SC
GROUP BY Sno
HAVING COUNT(*) >= 2;
```
5. 检索选修课程号为1和2的学生学号:
```
SELECT Sno
FROM SC
WHERE Cno IN ('1', '2');
```
6. 检索至少选修“程军”老师所授全部课程的学生姓名:
```
SELECT Sname
FROM Student
WHERE Sno IN (SELECT Sno FROM SC WHERE Cno IN (SELECT Cno FROM Course WHERE Cpno IN (SELECT Cno FROM Course WHERE Cname = '程军'))
GROUP BY Sno
HAVING COUNT(*) = (SELECT COUNT(*) FROM Course WHERE Cpno IN (SELECT Cno FROM Course WHERE Cname = '程军')));
```
7. 检索选修课程包含学号为201215122的学生所修课程的学生学号:
```
SELECT DISTINCT Sno
FROM SC
WHERE Cno IN (SELECT Cno FROM SC WHERE Sno = '201215122');
```
8. 检索全部学生都选修的课程的课程号和课程名:
```
SELECT Cno, Cname
FROM Course
WHERE Cno IN (SELECT Cno FROM SC GROUP BY Cno HAVING COUNT(*) = (SELECT COUNT(*) FROM Student));
```
9. 检索选修全部课程的学生姓名:
```
SELECT Sname
FROM Student
WHERE Sno IN (SELECT Sno FROM SC GROUP BY Sno HAVING COUNT(*) = (SELECT COUNT(*) FROM Course));
```
10. 查询所在系是CS系的学生选修的课程的课程名和学分,结果按课程名降序排序:
```
SELECT C.Cname, C.Ccreadit
FROM SC AS S
JOIN Course AS C ON S.Cno = C.Cno
JOIN Student AS St ON S.Sno = St.Sno
WHERE St.Sdept = 'CS'
ORDER BY C.Cname DESC;
```
11. 检索“数据库”课程成绩高于90分的所有学生的学号、姓名和分数:
```
SELECT S.Sno, S.Sname, SC.Grade
FROM Student AS S
JOIN SC ON S.Sno = SC.Sno
JOIN Course AS C ON SC.Cno = C.Cno
WHERE C.Cname = '数据库' AND SC.Grade > 90;
```
12. 查询男生和女生选修课程的平均成绩:
```
SELECT S.Ssex, AVG(SC.Grade) AS AvgGrade
FROM Student AS S
JOIN SC ON S.Sno = SC.Sno
GROUP BY S.Ssex;
```
13. 检索没有选课的学生的学号和姓名:
```
SELECT S.Sno, S.Sname
FROM Student AS S
WHERE S.Sno NOT IN (SELECT Sno FROM SC);
```
14. 检索没有任何一门课程成绩不及格的学生的信息,包括学号、姓名:
```
SELECT S.Sno, S.Sname
FROM Student AS S
WHERE S.Sno NOT IN (SELECT Sno FROM SC WHERE Grade < 60);
```
阅读全文