[Oracle]見習BI工程師

打開sqldeveloper
----新建連接----
----新建會話----
----新建會話級臨時表----


select * from emp;

----新建中間表 再查找----

with bt as (select emp.*
				   ,rank() over(partition by deptno order by sal desc) rank from emp)
select * from bt where rank<=3; 

----函數-----
–聚合函數–
sum()
avg()
count()
max()
min()
–分析函數–
排名函數
rank() over(partition by 字段 order by 字段)在這裏插入圖片描述








row_number over(partition by 字段 order by 字段)
在這裏插入圖片描述

dense_rank() over(partition by 字段 order by 字段)
~~在這裏插入圖片描述~~
遷移函數
lead() 上移


select ename 姓名
	   ,round((lead(sal,2) over(order by hiredate) -sal)/sal,3)*100||'%' 環比 from emp;

在這裏插入圖片描述
lag() 下移

聚合分析函數
sum(字段) over(order by 字段)

select ename 姓名
	   ,sal 工資
	   ,sum(sal) over(order by hiredate) 累計工資 from emp;

在這裏插入圖片描述
avg(字段) over(order by 字段)
count(字段) over(order by 字段)
max(字段) over(order by 字段)
min(字段) over(order by 字段)



下一篇:半連接-相關子查詢

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章