1. Get unlimited access to documents by upgrading to Premium Membership.
Afsur Hussain

PL/Sql query result Transpose using PIVOT 1.0

Query Row Values to Columns

  1. Afsur Hussain
    Code (SQL):
    SELECT * FROM
    (
    SELECT to_char(invoice_date,'Mon') Month_Name,to_char(invoice_date,'YYYY') YEAR, invoice_num No_of_Invoices
    FROM AP_invoices_all
    WHERE to_char(invoice_date,'YYYY') BETWEEN to_char(sysdate,'YYYY')-5 AND to_char(sysdate,'YYYY')
    )
    PIVOT
    (
      COUNT(No_of_Invoices)
      FOR Month_Name IN ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec')
    )
    ORDER BY YEAR