Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> SUM and DECODE

SUM and DECODE

From: CRISTIAN FERRERO <CRISTIAN_FERRERO_at_HOTMAIL.COM>
Date: 3 Feb 2005 04:16:00 -0800
Message-ID: <101b8936.0502030416.f26952e@posting.google.com>


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

GROUP BY C.NRO_ORDEN,C.DESC_CUENTA,C.OBSERVACIONES ORDER BY C.NRO_ORDEN;  like you see i have a group by
C.NRO_ORDEN,C.DESC_CUENTA,C.OBSERVACIONES the problem is that one of the reg that takes the sum must be (-) instead of (+).....how can i identify it ?? i thougt using another nested decode, but all the fields must have the same value because of the group by.....

tks Received on Thu Feb 03 2005 - 06:16:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US