select buyer_name,currency,sum(net_amt) net_amt from ( select m.buyer_name,n.OLD_INVOICE_NO,n.despatch_date invoice_date, ( SELECT B.CUR_abbr FROM MREL.MREL_CURRENCY_MASTER B,SALES.SALES_SALEADV_MASTER A WHERE A.SALE_ADV_NO=( select y.MILL_ORDER_NO from SALES_EXPORT_INVOICE_QUALITY y,sales_export_invoice_master x where x.despatch_code = y.despatch_code and x.comp_code = y.comp_code and x.old_invoice_no = n.old_invoice_no and rownum <= 1) AND A.COMP_CODE = 3 AND B.CURR_CODE = A.CURR_CODE ) currency , n.net_amount NET_AMT from sales_export_invoice_master n,mrel.MREL_SALES_BUYER_MAST m where n.buyer_code = m.buyer_code and n.despatch_date between '01-APR-2009' AND '31-DEC-2009' ORDER BY 1 ) group by buyer_name,currency order by 1