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

    Unanswered: Oracle 9i SQL, additional column

    Hi, I have the following query:

    select c.CUSTOMERNO, dm.INVOICEMONTH,
    sum(dm.PRODUCTCOUNT1) as PORTAL_VOL
    from debmonthly dm, monitororder mo, customer c, employee e
    where mo.ORDERNO = dm.ORDERNO
    and mo.CUSTOMERNO = c.CUSTOMERNO
    and c.SALESPERSONID = e.USERID
    and c.SALESPERSONID in (3961,1074,5122)
    and dm.PRODUCTNO in (8285,1287,2287,3287,1387,2387,3387,1289)
    group by c.CUSTOMERNO, dm.INVOICEMONTH,

    which provides the following example results:

    CUSTOMERNO INVOICEMONTH PORTAL_VOL
    1 May 2004 10
    1 Jun 2004 15
    2 May 2004 50
    2 Jun 2004 75
    2 Jul 2004 100
    3 Jun 2004 5
    etc...

    I want to be able to have another column within the same result set showing different product volumes, i.e.:

    CUSTOMERNO INVOICEMONTH EMAIL_VOL FAX_VOL
    1 May 2004 10 2
    1 Jun 2004 15 0
    1 Jul 2004 0 10
    2 May 2004 50 5
    2 Jun 2004 75 0
    2 Jul 2004 100 10
    3 May 2004 0 25
    3 Jun 2004 5 0
    etc...

    How can I acheive this?

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

    Cool

    Search from 'PIVOT TABLE' or "CROSSTAB" in:


    http://asktom.oracle.com

    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
  •