Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Location
    London
    Posts
    76

    Unanswered: Pivot Tables using SQL

    Hi,

    I need some help in writing an SQL script that would convert the results into a pivot table in Toad. I am extracting data from an Oracle database.

    I need to have each post date as a column header from the SQL below:

    select ca.ACCOUNT_ID, cd.CLIENT_NAME, od.post_date, sum(oi.PRICE)
    from order_details od, client_details cd, client_account ca, order_items oi
    where od.DELETED = 0
    and od.SERVICE_ID = 300009
    and cd.CLIENT_ID = od.CLIENT_ID
    and cd.CLIENT_ID = ca.CLIENT_ID
    and od.ORDER_ID = oi.ORDER_ID
    and od.INVOICE_DATE = oi.IDATE
    group by ca.ACCOUNT_ID, cd.CLIENT_NAME, od.post_date

    Thanks for any help

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

  3. #3
    Join Date
    Feb 2004
    Location
    London
    Posts
    76
    Thanks...will have a look

  4. #4
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool

    Also, this question has been asked and answered many times on many forums, just search for 'PIVOT TABLE' or 'CROSS TAB QUERY'.
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •