Good afternoon all!
Ok, I need one query to do something rather complicated. Break out your SQL skills!
I have 3 tables.
Table 1 = Project
Table 2 = Project_Test_CB
Table 3 = Project_Test_BDR
The 'Project' table has a primary key named "PMT_No".
Tables 2 and 3 have further information about each "PMT_No" so they are each linked with an inner join on PMT_No on Project. Note: Project simply has ALL the "PMT_No"s...one might or might not be in Table 2 or Table 3.
Next we have "Pass_CB" (located in Table 2) and "Pass_BDR" located in Table 3. These combined with PMT_No is a primary key for Table 2 and 3 respectively.
Finally, we have "Test_Cond_CB" (located in Table 2) and "Test_Cond_BDR" (located in Table 3). These fields are Integers.
I need a SQL statement that will SUM the "Test_Cond_CB" field AND SUM the "Test_Cond_BDR" fields for each Pass AND THEN ADD that result together. Example: For EACH PMT_No (34B, 26E, and 56Y for example) add up the "Test_Cond_CB" for each Pass. Same thing for "Test_Cond_BDR". THEN ADD "Test_Cond_BDR" and "Test_Cond_CB" together for each Pass.
More examples: Say PMT_NO is "AM1234". Pass_CB and Pass_BDR are both 1. And "Test_Cond_BDR" is 5 while "Test_Cond_CB" is 10.
The final results should be:
Pass SumOfTestConditions
1 15
So I need to group by Pass.
Here are the tables and attributes in case you didn't follow:
"Project" Table:
PMT_No (PK)
"Project_Test_CB" Table:
PMT_No (PK)
Pass_CB (PK) (possible values are only 1, 2, or 3)
Test_Cond_CB (an integer)
"Project_Test_BDR" Table:
PMT_No (PK)
Pass_BDR (PK) (possible values are only 1, 2, or 3)
Test_Cond_BDR (an integer)
Does anyone know how to do this??? I've been working on this all morning but to no avail. I need someone bigger than I to answer this.![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
THANKS!!
-Tim
Ok, I need one query to do something rather complicated. Break out your SQL skills!
I have 3 tables.
Table 1 = Project
Table 2 = Project_Test_CB
Table 3 = Project_Test_BDR
The 'Project' table has a primary key named "PMT_No".
Tables 2 and 3 have further information about each "PMT_No" so they are each linked with an inner join on PMT_No on Project. Note: Project simply has ALL the "PMT_No"s...one might or might not be in Table 2 or Table 3.
Next we have "Pass_CB" (located in Table 2) and "Pass_BDR" located in Table 3. These combined with PMT_No is a primary key for Table 2 and 3 respectively.
Finally, we have "Test_Cond_CB" (located in Table 2) and "Test_Cond_BDR" (located in Table 3). These fields are Integers.
I need a SQL statement that will SUM the "Test_Cond_CB" field AND SUM the "Test_Cond_BDR" fields for each Pass AND THEN ADD that result together. Example: For EACH PMT_No (34B, 26E, and 56Y for example) add up the "Test_Cond_CB" for each Pass. Same thing for "Test_Cond_BDR". THEN ADD "Test_Cond_BDR" and "Test_Cond_CB" together for each Pass.
More examples: Say PMT_NO is "AM1234". Pass_CB and Pass_BDR are both 1. And "Test_Cond_BDR" is 5 while "Test_Cond_CB" is 10.
The final results should be:
Pass SumOfTestConditions
1 15
So I need to group by Pass.
Here are the tables and attributes in case you didn't follow:
"Project" Table:
PMT_No (PK)
"Project_Test_CB" Table:
PMT_No (PK)
Pass_CB (PK) (possible values are only 1, 2, or 3)
Test_Cond_CB (an integer)
"Project_Test_BDR" Table:
PMT_No (PK)
Pass_BDR (PK) (possible values are only 1, 2, or 3)
Test_Cond_BDR (an integer)
Does anyone know how to do this??? I've been working on this all morning but to no avail. I need someone bigger than I to answer this.
THANKS!!
-Tim