I need to get the adue_cd and group by the sum of the adue_amt- amtpd based on the decoded code ??
SELECT DECODE(adue_cd,'DS','STM','IS','INS','MS','OUI', 'PA','OD1','PN','OD2','PP','OD1') ,SUM(adue_amt - amt_pd) FROM BSADUE WHERE la_no = v_la_no AND adue_cd IN ('DS','IS','MS','PA','PN','PP') GROUP BY adue_cd order by DECODE(adue_cd,'DS','STM','IS','INS','MS','OUI', 'PA','OD1','PN','OD2','PP','OD1') here is my explain plan generate from TOAD. Operation Object Name Rows Bytes Cost TQ In/Out PStart PStop SELECT STATEMENT SORT ORDER BY SORT GROUP BY TABLE ACCESS BY INDEX ROWID BSADUE INDEX RANGE SCAN BSADUE_LANO Raymond Lee Infopro Sdn Bhd "Do not criticize someone until you walked a mile in their shoes, that way when you criticize them, you are a mile a way and have their shoes." -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Raymond Lee Meng Hong INET: [EMAIL PROTECTED] Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).