**g:平均函式
max:最大值函式
min:最小值函式
sum:求和函式
stddev:標準差函式
count():計數函式
例子1:對員工表查詢平均工資、最高工資、最低工資、標準差工資、總工資、總員工數
select round(**g(salary),2) "平均工資",max(salary) "最高工資",min(salary) "最低工資",round(stddev(salary), 2) "標準差工資",sum(salary) "總工資" ,count(employee_id) "總員工數" from employees
例子2:通過distinct統計員工的部門數量
select count(distinct department_id) from employees;
1、對單列分組:查詢employees表中各部門的平均工資
2、對多列分組:查詢employees表中各部門、各工種的平均工資
1、求出各部門中平均工資大於6000的部門
1、求出各部門中平均工資的最大值
1、查詢公司員工工資的最大值,最小值,平均值,總和
2、查詢各job_id的員工工資的最大值,最小值,平均值,總和
3、選擇各個job_id的員工人數
4、查詢員工最高工資和最低工資的差距(difference)
5、查詢各個管理者手下員工的最低工資,其中最低工資不能低於6000,沒有管理者的員工不計算在內
6、查詢所有部門的名字,location_id,員工數量和工資平均值
select department_name,location_id,count(employee_id),**g(salary) from employees e right outer join departments d on e.department_id = d.department_id
group by department_name,location_id
7、查詢公司在1995-2023年之間,每年雇用的人數,結果類似下面的格式
total
select count(*) "total",
count(decode(to_char(hire_date,'yyyy'),'1995',1,null)) "1995",
count(decode(to_char(hire_date,'yyyy'),'1996',1,null)) "1996",
count(decode(to_char(hire_date,'yyyy'),'1997',1,null)) "1997",
count(decode(to_char(hire_date,'yyyy'),'1998',1,null)) "1998"
from employees
where to_char(hire_date,'yyyy') in ('1995','1996','1997','1998')
oracle資料庫引用arcgis地理函式庫
隨著arcgis軟體的迭代,arcgis連線資料已經從以前的需要安裝arcsde外掛程式發展成可以直連資料的地步了,但是很多從低版本過渡過來的人卻在新版本arcgis軟體安裝和註冊資料庫後無法使用arcgis st庫函式,這是因為資料庫沒有正確的引用arcgis st庫函式的的原因。如何正確的引用函...
學習筆記 03 oracle資料庫教程 單行函式
立即學習 字串擷取substr str,begin,len 從1開始數 length字元數 lengthb位元組數 utf 8編碼格式下 1個漢字佔3個位元組 gbk 1比2 select from nls database parameters 檢視當前系統編碼格式 instr str,subst...
oracle資料庫學習
最近在做使用者資料篩選的時候發現使用者資料載入和查詢比較慢,所以,參考網上資料進行了寫小優化,在資料庫中執行快了那麼一些,在這裡記錄下相關命令。做法 建立字段索引,使用instr函式。1 使用instr代替like 開頭會導致索引失效 instr的基本用法 select count from 表名 ...