This is regarding the return of order line issues per user in a query.
tblUser owns many tblLines, some of these order lines will have issues which are stored in tblLine_Issue (via tblLine & tblIssue_Type keys).
Line issue types are stored in tblIssue_Type (14 possibilities).
So, a user may have 0 or many orders, each of which may have 0 or many issues, which are stored in tblLine_Issue which are linked to tblIssue_Type.
Here are the tables / relationships:
[tt]
tblUser tblLine tblLine_Issue tblIssue_Type
pk <-| pk <-->> line_fk |-->pk
name | Line_No issue_fk <<--| issue
|->> user_fk
[/tt]
I have a requirement to retrieve a count of lines with types of issues for each user, and it must display ALL issue-types (even if the user has zero order lines with that issue).
Example output would be:[tt]
User Issue Type # Issues
1 1 0
1 2 0
1 3 2
1 : :
1 14 0
2 1 3
2 2 2
2 3 0
2 : :
2 14 5
[/tt](The colon ' : ' indicates issue types 4..13).
So, there needs to be 14 rows (14 issue types) per user regardless of whether or not they own order-lines that have that issue.
I think that some kind of union with tblIssue_Type is required - but ...
I know that this to a SQL guru is bread & butter, but despite my best efforts - I'm stuck.
Any help much appreciated.
ATB
Darrylle
Never argue with an idiot, he'll bring you down to his level - then beat you with experience.
tblUser owns many tblLines, some of these order lines will have issues which are stored in tblLine_Issue (via tblLine & tblIssue_Type keys).
Line issue types are stored in tblIssue_Type (14 possibilities).
So, a user may have 0 or many orders, each of which may have 0 or many issues, which are stored in tblLine_Issue which are linked to tblIssue_Type.
Here are the tables / relationships:
[tt]
tblUser tblLine tblLine_Issue tblIssue_Type
pk <-| pk <-->> line_fk |-->pk
name | Line_No issue_fk <<--| issue
|->> user_fk
[/tt]
I have a requirement to retrieve a count of lines with types of issues for each user, and it must display ALL issue-types (even if the user has zero order lines with that issue).
Example output would be:[tt]
User Issue Type # Issues
1 1 0
1 2 0
1 3 2
1 : :
1 14 0
2 1 3
2 2 2
2 3 0
2 : :
2 14 5
[/tt](The colon ' : ' indicates issue types 4..13).
So, there needs to be 14 rows (14 issue types) per user regardless of whether or not they own order-lines that have that issue.
I think that some kind of union with tblIssue_Type is required - but ...
I know that this to a SQL guru is bread & butter, but despite my best efforts - I'm stuck.
Any help much appreciated.
ATB
Darrylle
Never argue with an idiot, he'll bring you down to his level - then beat you with experience.