If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > SQL in Oracle 9i, merging columns

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-15-04, 10:53
dsehmby dsehmby is offline
Registered User
 
Join Date: Feb 2004
Location: London
Posts: 76
SQL in Oracle 9i, merging columns

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?
Reply With Quote
  #2 (permalink)  
Old 07-15-04, 12:17
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Sorry, maybe I'm being dense, but what does this new column represent?
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #3 (permalink)  
Old 07-15-04, 13:51
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,455
Thumbs down

Quote:
Originally Posted by andrewst
Sorry, maybe I'm being dense, but what does this new column represent?
andrewst Don't you recognize the same old 'crosstab/pivot' table scene?
Seem's every day there is someone lazy not doing any research, tossing out the same question over and over and over again in every single forum in existence.

__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #4 (permalink)  
Old 07-16-04, 05:08
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Right you are - I didn't notice that the 3rd column's header had changed!
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On