Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Sum from 2 tables

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-07-25 : 14:44:41
David writes "I am looking for a stored proc to return the sum of results from 3 tables. I'll explain the table structure first.

Table1:
Table1ID
intField1
bitField1

Table2:
Table2ID
intField2
bitField2
Table1ID

Table3:
Table3ID
intField3
bitField3
Table2ID

There is a one to many join between Table1 and Table2, and another between Table2 and Table3. The Fields that are called bitField* store a 1 or 0. The Fields intField* are int.

What I want is to get the sum of all the values for intField2 and intField3 for each record in Table1. The bitField* fields act as a 'switch'. If they are 1 I don't want to include them in the sum."
   

- Advertisement -