View previous topic :: View next topic
|
Author |
Message |
athosar1984
New User
Joined: 22 Sep 2009 Posts: 5 Location: Pune
|
|
|
|
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 |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
you can use subselect or having clause.
This depends on how Table A and B are grouped and/or joined |
|
Back to top |
|
|
sachin_star3 Warnings : 1 New User
Joined: 30 Sep 2006 Posts: 78 Location: pune
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
How does this query compare the sum to a column from the other table? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Congratulations sachin_star3,
Wednesday must be psychic day for you! |
|
Back to top |
|
|
|