IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

DB2 Column Fuction Compare


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
athosar1984

New User


Joined: 22 Sep 2009
Posts: 5
Location: Pune

PostPosted: Wed Nov 18, 2009 1:05 pm
Reply with quote

Suppose there are 2 tables A and B

I want to use DB2 column function(SUM) on one field of table A
and this SUM is to be compared with one field from table B.

how i can accomplish this?
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Nov 18, 2009 1:47 pm
Reply with quote

you can use subselect or having clause.
This depends on how Table A and B are grouped and/or joined
Back to top
View user's profile Send private message
sachin_star3

New User


Joined: 30 Sep 2006
Posts: 78
Location: pune

PostPosted: Thu Nov 19, 2009 12:39 am
Reply with quote

please try the below query:

select * from table b where salary in (
select sum(salary) from table a where emp name ='vinod'
group by salary)
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Thu Nov 19, 2009 1:13 am
Reply with quote

Hello,

How does this query compare the sum to a column from the other table?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6965
Location: porcelain throne

PostPosted: Thu Nov 19, 2009 1:57 am
Reply with quote

Quote:
emp name ='vinod'


Congratulations sachin_star3,

Wednesday must be psychic day for you!
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Compare the member of two pds on las... DFSORT/ICETOOL 13
No new posts Extract ISPF table column headings CLIST & REXX 2
No new posts JCL sort to compare dates in two file... DFSORT/ICETOOL 2
No new posts Compare 2 alphabets in a REXX and fin... CLIST & REXX 2
No new posts ISPF Table to add a new column TSO/ISPF 1
Search our Forums:


Back to Top