over 开窗函数使用说明

---CUR_CD              VARCHAR2(18)   Y                币种 

---CORP_ORG            VARCHAR2(10)                    法人机构编号 

---AGMT_ID             VARCHAR2(40)                    合同号  

---BUSINESSTYPE        VARCHAR2(18)   Y                业务品种

----此SQL含义 汇总 b.cur_cd, b.Corp_Org取一行

select * from (SELECT b.Agmt_Id,
                          b.Corp_Org,
                          b.Cur_Cd,
                          b.Businesstype,
                          
                          Row_Number() Over(PARTITION BY b.cur_cd, b.Corp_Org  ORDER BY b.cur_cd, b.Corp_Org) Row_No
                     FROM dwm.b_m_Business_Contract b)
                     where Row_no=1
        AGMT_ID                 CORP_ORG CUR_CD  BUSINESSTYPE   Row_No
1	20120801000126	        15601	T00CNY	2050030	        1
2	320090419000005	        15601	T00CNY	3010	        2
3	20130129000184	        15601	T00CNY	2050030	        3
4	200612750372093-5	15601	T00CNY		        4
5	200612750373093-1	15601	T00CNY		        5
6	200612750373093-2	15601	T00CNY		        6
7	200612750373093-3	15601	T00CNY		        7
8	200612750373093-4	15601	T00CNY		        8
9	200712750081093-3	15601	T00CNY	2010	        9
10	20090417000135	        15601	T00CNY	1020010	       10
11	200612750046-2	        15601	T00CNY		       11
12	200612750046-3	        15601	T00CNY		       12
13	200606750002-1	        15601	T00CNY		       13
14	200606750002-2	        15601	T00CNY		       14
15	200606750003	        15601	T00CNY	2012	       15
16	200606750004	        15601	T00CNY		       16
17	200606750005	        15601	T00CNY		       17
18	200606750007	        15601	T00CNY		       18
19	200606750010	        15601	T00CNY		       19

你可能感兴趣的:(over 开窗函数使用说明)