1:學生表blog
2:成績表數學
1.查詢全部學生的數學成績,顯示學生姓名name, 分數, 由高到低
select s.name,g.kemu,g.score from student s,grade g where s.id=g.id and g.kemu="數學" order by g.score desc
2.統計每一個學生的總成績,顯示字段:姓名,總成績
select s.name, sum(g.score) from student s inner join grade g on s.id=g.id group by s.name
3.統計每一個學生的總成績(因爲學生可能有重複名字),顯示字段:學生id,姓名,總成績
select s.id,s.name, sum(g.score) from student s inner join grade g on s.id=g.id group by s.id order by s.id
4.列出各門課程成績最好的學生, 要求顯示字段: 學號,姓名,科目,成績 select s.id,s.name,g.kemu, max(g.score) from student s inner join grade g on s.id=g.id group by g.kemu