从student表中查询年龄18~25岁的学生信息 查询张三的考试科目和考试成绩 计算每个学生的总成绩 将计算机考试成绩按从高到低进行排序
时间: 2024-06-14 18:05:01 浏览: 94
Asp+Txt通用考试成绩查分系统(2)条件电脑网页版
以下是根据提供的引用内容回答您的问题:
1. 从student表中查询年龄18~25岁的学生信息:
```sql
SELECT * FROM student WHERE age BETWEEN 18 AND 25;
```
2. 查询张三的考试科目和考试成绩:
```sql
SELECT c_name, grade FROM score WHERE stu_id = (SELECT id FROM student WHERE name = '张三');
```
3. 计算每个学生的总成绩:
```sql
SELECT student.id, student.name, SUM(score.grade) AS total_grade
FROM student
JOIN score ON student.id = score.stu_id
GROUP BY student.id, student.name;
```
4. 将计算机考试成绩按从高到低进行排序:
```sql
SELECT * FROM score WHERE c_name = '计算机' ORDER BY grade DESC;
```
阅读全文