Discussion Locked

Trouble Querying Database

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a table with a list of issues (includes duplicates) associated with a file name. There is a separate query that's linked to this table by file name and includes about 10 calculated fields associated with the file name (no duplicates). I would like to create a query that will add the 10 calculated fields together and sum them up by Issue#. Example:

Table#1
Issue# FileName
CR1 a.txt
CR2 a.txt
CR2 b.txt
CR2 c.txt

Table#2
FileName HrEst STEst BuildEst
a.txt 2 3 4
b.txt 1 4 6
c.txt 2 4 5

So for CR#1 I should get 9 and for CR#2 I should get 31. Understand? Any help would be GREATLY appreciatd. Thanks.

1 reply

by gary_w

This works in Oracle:

select sum(b.HREST+b.STEST+b.BUILDEST)
from gcw1 a, gcw2 b
where a.ISSUE = 'CR2'
and a.FILENAME = b.FILENAME

SQL> select sum(b.HREST+b.STEST+b.BUILDEST)
2 from gcw1 a, gcw2 b
3 where a.ISSUE = 'CR2'
4 and a.FILENAME = b.FILENAME;

SUM(B.HREST+B.STEST+B.BUILDEST)
-------------------------------
31

Gary

This discussion is closed to new replies.