Friday, February 23, 2018

Oracle SQL Multiple rows of single column to a single row

Multiple Rows are consolidated and displayed in a single row by LISTAGG function.
LISTAGG(<Column Name>,' ') WITHIN GROUP (ORDER BY<Column Number>)

 SELECT LISTAGG(LOT_NUMBER,' ') WITHIN GROUP (ORDER BY transaction_id) AS description
  FROM apps.mtl_transaction_lot_numbers
 WHERE transaction_id=60084;