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 > Database Server Software > DB2 > Union Clause

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-01-05, 14:57
Vichudha Vichudha is offline
Registered User
 
Join Date: Apr 2004
Posts: 4
Question Union Clause

I have to summarize the columns that are returned from a UNION ALL
in a cursor .

I tried to treat the resultant UNION ALL as a table and do the grouping but didn't work

Can anyone give me a hint ?
Reply With Quote
  #2 (permalink)  
Old 02-01-05, 16:10
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Something like this maybe:

with temp1 as (
select col1,col2 from mytable1
union all
select col1,col2 from mytable2
) select count(*),sum(col1),avg(col2) from temp1

Andy
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