<form id="hz9zz"></form>
  • <form id="hz9zz"></form>

      <nobr id="hz9zz"></nobr>

      <form id="hz9zz"></form>

    1. 明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

      SQL的聚合函數與排序

      [摘要]這次給大家帶來SQL的聚合函數與排序,使用SQL聚合函數與排序的注意事項有哪些,下面就是實戰案例,一起來看一下。count 函數語法:Select count(*) count(列名) from t...
      這次給大家帶來SQL的聚合函數與排序,使用SQL聚合函數與排序的注意事項有哪些,下面就是實戰案例,一起來看一下。

      count 函數

      語法:

      Select count(*) count(列名) from table_name [where where_defination];Select count(id) from stu;Select count(name) from stu where math > 90;select count (name) from stu where chines+math+English> 250;

      sum函數

      Select sum (列名) from stu [where where_defination];
      Select sum (列名),sum(列名), sum(列名) from stu [where where_definition];
      Select sum (列名)+sum(列名)+ sum(列名) from stu [where where_definition];
      Select sum (列名)+sum(列名)+sum(列名) as 總分 from stu [where where_definition];
      Select sum (列名)/count(name) from stu [where where_defination];
      Select avg(math) from stu;
      Select avg(math + chines + english) from stu;
      Select max min(列名) from stu;
      Select max(math + chines + english) from stu;
      Select min(math + chines + english) from stu;

      查詢結果排序

      使用order by 子句排序查詢結果

      Select column1, column2, column3 from table order by column asc desc

      order by指排序的列,也可以是select后面指定的列名

      order by 子句應位于select 語句的結尾

      Select name, math from stu order by math;
      select name, math+english+chines from stu order by math+english+chines desc;
      select name, math+english+chines from stu where name like 'zhang%' order by math+english+chines desc;

      2091014-cddde956b411ea7e.png

      2091014-9c52af8396187699.png

      相信看了本文案例你已經掌握了方法,更多精彩請關注php中文網其它相關文章!

      推薦閱讀:

      分頁查詢的使用詳解

      JS的日期相關函數使用詳解

      以上就是SQL的聚合函數與排序的詳細內容,更多請關注php中文網其它相關文章!


      學習教程快速掌握從入門到精通的SQL知識。




      日韩精品一区二区三区高清