oracle常用sql查詢語句部分集合(圖文)建站知識
導讀:1建站知識這篇文章主要介紹了oracle常用sql查詢語句部分,并用圖文并茂的方式為大家進程實例說明,需要的朋友可以參考下網站建設制作企業網站建設。
Oracle查詢語句
select * from scott.emp ;
1.--dense_rank()分析函數(查找每個部門工資最高前三名員工信息)
select * from (select deptno,ename,sal,dense_rank() over(partition by deptno order by sal desc) a from scott.emp) where a<=3 order by deptno asc,sal desc ;
結果:
--rank()分析函數(運行結果與上語句相同)
select * from (select deptno,ename,sal,rank() over(partition by deptno order by sal desc) a from scott.emp ) where a<=3 order by deptno asc,sal desc ;
結果:
--row_number()分析函數(運行結果與上相同)
select * from(select deptno,ename,sal,row_number() over(partition by deptno order by sal desc) a from scott.emp) where a<=3 order by deptno asc,sal desc ;
--rows unbounded preceding 分析函數(顯示各部門的積累工資總和)
select deptno,sal,sum(sal) over(order by deptno asc rows unbounded preceding) 積累工資總和 from scott.emp ;
結果:
--rows 整數值 preceding(顯示每最后4條記錄的匯總值)
select deptno,sal,sum(sal) over(order by deptno rows 3 preceding) 每4匯總值 from scott.emp ;
結果:
--rows between 1 preceding and 1 following(統計3條記錄的匯總值【當前記錄居中】)
select deptno,ename,sal,sum(sal) over(order by deptno rows between 1 preceding and 1 following) 匯總值 from scott.emp ;
結果:
--ratio_to_report(顯示員工工資及占該部門總工資的比例)
select deptno,sal,ratio_to_report(sal) over(partition by deptno) 比例 from scott.emp ;
結果:
--查看所有用戶
select * from dba_users ;
select count(*) from dba_users ;
select * from all_users ;
select * from user_users ;
select * from dba_roles ;
--查看用戶系統權限
select * from dba_sys_privs ;
select * from user_users ;
--查看用戶對象或角色權限
select * from dba_tab_privs ;
select * from all_tab_privs ;
select * from user_tab_privs ;
--查看用戶或角色所擁有的角色
select * from dba_role_privs ;
select * from user_role_privs ;
-- rownum:查詢10至12信息
select * from scott.emp a where rownum<=3 and a.empno not in(select b.empno from scott.emp b where rownum<=9);
結果:
--not exists;查詢emp表在dept表中沒有的數據
select * from scott.emp a where not exists(select * from scott.dept b where a.empno=b.deptno) ;
結果:
--rowid;查詢重復數據信息
聲明: 本文由我的SEOUC技術文章主頁發布于:2023-05-22 ,文章oracle常用sql查詢語句部分集合(圖文)建站知識主要講述語句,常用,oracle常用sql查詢語句部分集合(圖文)建網站建設源碼以及服務器配置搭建相關技術文章。轉載請保留鏈接: http://www.bifwcx.com/article/web_5154.html