回覆列表
  • 1 # 使用者5881545220793

    學生表名為:student, 單科成績的欄位為:subject。學生名字為:name 查詢單科成績前十:mysql語句為:select * from student order by subject desc limit 10; 查詢總分成績前十:mysql語句為:select sum(subject) subject,name from student group by name order by subject desc limit 10; 注: select sum(subject) subject,name 這句的意思是:sum(subject) subject 把單科成績加總用subject 來命名(就是總成績),name就是一個欄位,這裡只有兩個欄位。 group by name order by subject : group by name 的意思按照名字這一欄來分組,當然,學生成績表名字有可能是一樣的,按照學號是最準確的,這裡只是舉個例子。 order by subject 這句的意思是按照總分成績排序,這裡的subject 是前面重新命名總分的意思。 select sum(subject) as countsubject,name from student group by name order by countsubject desc limit 10;

  • 中秋節和大豐收的關聯?
  • 皮帶長度應該怎麼選擇?