一、去重distinct 語法格式:select distinct 列名稱 from 表名稱 二、統計函式 avg(x) count(1) count(*) max(x) min(x) sum(x) stddev(x) 求一組行中列x值的標準差 variance(x) 求一組行中列x值的方差 round與trunc: select round(avg(sal),4) from emp; 四舍五入,取整 select trunc(avg(sal),4) from emp; 不管小數點精確位數的后一位有多大都不進1 三、 1、分組查詢(關鍵字):group by 2、篩選過濾(關鍵字):having select deptno,max(sal) from emp group by deptno; 當使用分組陳述句時,在select陳述句中出現的列,一定要在group by中出現 select deptno job,avg(sal) from emp group by deptno,job; having陳述句 有having陳述句一定有group by陳述句,反之不一定, select deptno ,avg(sal) from emp group by deptno having avg(sal)>2000; 3、排序 order by 1)、order by子句在整個select陳述句中的位置始終位于最后, 2)、asc表升序,一般默認與省略,desc表降序, 3)、空值是最大的, 4)、其后可跟多列,依次對列進行排序, 四、連接查詢 1.內連接:顯式內連接(inner join on)、隱式內連接(where and ) 2.外連接:左外連接(left join)、右外連接(right join)、完整外連接(full join)

轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/214431.html
標籤:其他
上一篇:Ubuntu 19.10安裝 sql server2019,安裝sqlcmd時出現錯誤
下一篇:請教:制作隨機抽學號小程式
