Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

alternative for LISTAGG and WITHIN GROUP

2992177Mar 2 2016 — edited Mar 3 2016

we have SQL query that use LISTAGG and  WITHIN GROUP in racle 12c. we wan to run the same query in Oracle 10 G. how should I convert that sql query?



Select x.company,

 

   sum(x.dom_amount) as dom_amount,

   sum(x.curr_amount) as curr_amount,

  LISTAGG(x.accounting_year, '; ') WITHIN GROUP (ORDER BY x.accounting_year) accounting_year,

  LISTAGG(x.accounting_period, '; ') WITHIN GROUP (ORDER BY x.accounting_period) accounting_period,

 

   count(x.voucher_no) no_of_vouchers,

  LISTAGG(x.voucher_no, '; ') WITHIN GROUP (ORDER BY x.voucher_no) voucher_no,

  LISTAGG(x.voucher_type, '; ') WITHIN GROUP (ORDER BY x.voucher_type) voucher_type

   from

  (Select a.company,

 

  (NVL(a.debet_amount,0) - NVL(a.credit_amount,0)) dom_amount,

 

  (NVL(a.currency_debet_amount,0) - NVL(a.currency_credit_amount,0)) curr_amount

   from gen_led_voucher_row_tab a

   where a.trans_code IN ('AFP1', 'AFP2', 'AFP5', 'AFP6', 'AFP7', 'AFP8')

   union all

   Select a.company,

 

  (NVL(a.debet_amount,0) - NVL(a.credit_amount,0)) dom_amount,

 

  (NVL(a.currency_debet_amount,0) - NVL(a.currency_credit_amount,0)) curr_amount

   from voucher_row_tab a

   where a.trans_code IN ('AFP1', 'AFP2', 'AFP5', 'AFP6', 'AFP7', 'AFP8')

 

   group by x.company,x.reference_serie,x.reference_number, x.trans_code,

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 31 2016
Added on Mar 2 2016
4 comments
9,965 views