Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> SUM and DECODE
Hi, i hav this select :
SELECT C.NRO_ORDEN,C.DESC_CUENTA,C.OBSERVACIONES,
DECODE(C.OBSERVACIONES,NULL,SUM(G.IMP_INICIO/1000),SUM(G.IMP_INICIO))
INICIO,
DECODE(C.OBSERVACIONES,NULL,SUM(G.IMP_YTD_ACTUAL/1000),SUM(G.IMP_YTD_ACTUAL))
YTD,
DECODE(C.OBSERVACIONES,NULL,SUM(G.IMP_MES_01/1000),SUM(G.IMP_MES_01))
ENE,
DECODE(C.OBSERVACIONES,NULL,SUM(G.IMP_MES_02/1000),SUM(G.IMP_MES_02))
FEB,
DECODE(C.OBSERVACIONES,NULL,SUM(G.IMP_MES_03/1000),SUM(G.IMP_MES_03))
MAR,
DECODE(C.OBSERVACIONES,NULL,SUM(G.IMP_MES_04/1000),SUM(G.IMP_MES_04))
APR,
DECODE(C.OBSERVACIONES,NULL,SUM(G.IMP_MES_05/1000),SUM(G.IMP_MES_05))MAY, DECODE(C.OBSERVACIONES,NULL,SUM(G.IMP_MES_06/1000),SUM(G.IMP_MES_06))JUN, DECODE(C.OBSERVACIONES,NULL,SUM(G.IMP_MES_07/1000),SUM(G.IMP_MES_07))JUL, DECODE(C.OBSERVACIONES,NULL,SUM(G.IMP_MES_08/1000),SUM(G.IMP_MES_08))AUG, DECODE(C.OBSERVACIONES,NULL,SUM(G.IMP_MES_09/1000),SUM(G.IMP_MES_09))SEP, DECODE(C.OBSERVACIONES,NULL,SUM(G.IMP_MES_10/1000),SUM(G.IMP_MES_10))OCT, DECODE(C.OBSERVACIONES,NULL,SUM(G.IMP_MES_11/1000),SUM(G.IMP_MES_11))NOV, DECODE(C.OBSERVACIONES,NULL,SUM(G.IMP_MES_12/1000),SUM(G.IMP_MES_12))DEC FROM IGM_SALDOS_GPU G, IGM_CUENTAS_INF C WHERE G.PERIODO = :P_PERIODO AND G.COD_CUENTA = C.COD_CUENTA AND C.CO_INF = 'E4An4' AND C.COD_CUENTA LIKE :P_EMPRESA||'%' AND C.NRO_ORDEN<>80
tks Received on Thu Feb 03 2005 - 06:16:00 CST