Oracle
 sql >> Base de Dados >  >> RDS >> Oracle

Posso usar a função analítica do Oracle aqui?


Claro, você pode usar análises, algo assim:
SELECT DISTINCT YEAR, MONTH, WEEK, CPG, DEPT, CUST_ID, R_ID,
       SUM(P1) OVER (PARTITION BY YEAR,MONTH,WEEK, CPG, DEPT, CUST_ID, R_ID) P1,
       SUM(IC) OVER (PARTITION BY YEAR,MONTH,WEEK, CPG, DEPT, CUST_ID, R_ID) IC,
       SUM(B1) OVER (PARTITION BY YEAR,MONTH,WEEK, CPG, DEPT, CUST_ID, R_ID) B1, 
       P2, B2, TOT, TOTAL_TXN, TOTAL_AMT 
  FROM (your_query)