Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

DB2 Column Fuction Compare

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: DB2 Column Fuction Compare
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    Post subject:
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
Warnings : 1

New User


Joined: 30 Sep 2006
Posts: 78
Location: pune

PostPosted: Thu Nov 19, 2009 12:39 am    Post subject: Reply to: DB2 Column Fuction Compare
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

Site Director


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

PostPosted: Thu Nov 19, 2009 1:13 am    Post subject:
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: 6967
Location: porcelain throne

PostPosted: Thu Nov 19, 2009 1:57 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts member list compare jzhardy TSO/ISPF 6 Fri May 12, 2017 3:18 pm
No new posts Compare two files and subtract values ameetmund DFSORT/ICETOOL 7 Fri Mar 31, 2017 3:35 pm
No new posts fuzzy compare Martylin JCL & VSAM 9 Thu Mar 30, 2017 2:45 pm
No new posts Storing huge volume of data, compare ... Pradeep K M All Other Mainframe Topics 3 Mon Jan 16, 2017 5:08 pm
This topic is locked: you cannot edit posts or make replies. DB2 query Using Recursion, Converting... smilewithashu2 DB2 3 Tue Jan 03, 2017 12:50 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us