Hi everyone,
I have a two tables with a one-to-many relationship between them.
Table 1: tblIssues
IssueID (Primary Key – Autonumber)
Table 2: tblSubIssues
IssueID (FK from tblIssues)
IAVerification (Value list - "Verified";"Not Yet Verified";"In Progress";"Passed";"N/A")
One IssueID can have multiple Verification values. For instance, this query:
SELECT tblIssue.IssueID, tblSubIssue.IAVerification
FROM tblIssue INNER JOIN tblSubIssue ON (tblIssue.IssueID = tblSubIssue.IssueID) AND (tblIssue.IssueID = tblSubIssue.IssueID);
Gives this result:
IssueID IAVerification
93 In Progress
93 Not Yet Verified
93 In Progress
94 Verified
94 In Progress
95 Verified
96 Not Yet Verified
97 Not Yet Verified
97 Verified
98 Verified
99 Not Yet Verified
100 Verified
101 Verified
101 Verified
101 In Progress
102 Not Yet Verified
102 Not Yet Verified
103 Verified
103 In Progress
103 In Progress
103 Not Yet Verified
104 Not Yet Verified
104 Not Yet Verified
104 Not Yet Verified
105 Verified
105 Not Yet Verified
I’m trying to write a query to “roll up” or summarize on the IssueID with the following preference criteria:
1. Not Yet Verified
2. In Progress
3. Verified
4. Passed
5. N/A
So the logic would be, if there is more than one IAVerification associated with an IssueID it would be filtered according to the list above. So for instance, Not Yet Verified takes precedence over all other values, if NYV doesn’t exist then In Progress takes precedence, etc. So the table above essentially becomes:
IssueID IAVerification
93 Not Yet Verified
94 In Progress
95 Verified
96 Not Yet Verified
97 Not Yet Verified
98 Verified
99 Not Yet Verified
100 Verified
101 In Progress
102 Not Yet Verified
103 Not Yet Verified
104 Not Yet Verified
105 Not Yet Verified
My gut tells me I need a subquery do this but I’m stumped as to how to craft the logic. Any assistance would be greatly appreciated. Thanks!
I have a two tables with a one-to-many relationship between them.
Table 1: tblIssues
IssueID (Primary Key – Autonumber)
Table 2: tblSubIssues
IssueID (FK from tblIssues)
IAVerification (Value list - "Verified";"Not Yet Verified";"In Progress";"Passed";"N/A")
One IssueID can have multiple Verification values. For instance, this query:
SELECT tblIssue.IssueID, tblSubIssue.IAVerification
FROM tblIssue INNER JOIN tblSubIssue ON (tblIssue.IssueID = tblSubIssue.IssueID) AND (tblIssue.IssueID = tblSubIssue.IssueID);
Gives this result:
IssueID IAVerification
93 In Progress
93 Not Yet Verified
93 In Progress
94 Verified
94 In Progress
95 Verified
96 Not Yet Verified
97 Not Yet Verified
97 Verified
98 Verified
99 Not Yet Verified
100 Verified
101 Verified
101 Verified
101 In Progress
102 Not Yet Verified
102 Not Yet Verified
103 Verified
103 In Progress
103 In Progress
103 Not Yet Verified
104 Not Yet Verified
104 Not Yet Verified
104 Not Yet Verified
105 Verified
105 Not Yet Verified
I’m trying to write a query to “roll up” or summarize on the IssueID with the following preference criteria:
1. Not Yet Verified
2. In Progress
3. Verified
4. Passed
5. N/A
So the logic would be, if there is more than one IAVerification associated with an IssueID it would be filtered according to the list above. So for instance, Not Yet Verified takes precedence over all other values, if NYV doesn’t exist then In Progress takes precedence, etc. So the table above essentially becomes:
IssueID IAVerification
93 Not Yet Verified
94 In Progress
95 Verified
96 Not Yet Verified
97 Not Yet Verified
98 Verified
99 Not Yet Verified
100 Verified
101 In Progress
102 Not Yet Verified
103 Not Yet Verified
104 Not Yet Verified
105 Not Yet Verified
My gut tells me I need a subquery do this but I’m stumped as to how to craft the logic. Any assistance would be greatly appreciated. Thanks!