select a.s_id ,a.s_name ,count(b.c_id) as sum_course ,sum(b.s_score)as sum_score from student a left join score b on a.s_id=b.s_id GROUP BY a.s_id,a.s_name
时间: 2024-04-13 10:29:40 浏览: 139
SELECT A.S_CLASS
Sure! Here is the SQL query to fulfill your request:
```sql
SELECT a.s_id, a.s_name, COUNT(b.c_id) AS sum_course, SUM(b.s_score) AS sum_score
FROM student a
LEFT JOIN score b ON a.s_id = b.s_id
GROUP BY a.s_id, a.s_name;
```
This query will retrieve the student ID (`s_id`), student name (`s_name`), the total number of courses taken by each student (`sum_course`), and the sum of scores obtained by each student (`sum_score`). The `LEFT JOIN` ensures that all students are included in the result, even if they don't have any scores recorded in the `score` table.
Let me know if you need any further assistance!
阅读全文