Using: Crystal Designer 8
DB: SQL2K
I need to sum quantity amount based on the maximum distinct count of items within a grouping. Example:
GroupHeader#1 Part Produced: ABC123
GroupHeader#2 PartUsed
ProductionNo PartUsed Qty Produced
1 MA111 500
2 MA111 100
3 MA111 200
GroupFooter#2 Total MA123: 800
1 CA222 500
2 CA222 100
3 CA222 200
4 CA222 -100
GroupFooter#2 Total CA222: 700
1 BB333 500
2 BB333 100
3 BB333 200
GroupFooter#2 Total BB333: 800
GroupFooter#1 Total Qty Produced for ABC: 700
I need to get the Summary Qty Produced (GroupFooter#1) for all the ProductionNumbers(1,2,3,4) for that Part Produced (ABC123) which is 700.
(1) What I have done is create a Running Total - distinct count.
(2) I need to identify the maximum value from the distinct count for each PartUsed Group.
(3) Then I need to display the Qty Produced summary for the maximum count. In the above example: Total CC222 has the maximum count = 4 - Qty Produced Sum = 700.
My problem: I cannot figure out the syntax to do (2) and (3).
Would really appreciate some help. Thanks in advance.
~matahari
DB: SQL2K
I need to sum quantity amount based on the maximum distinct count of items within a grouping. Example:
GroupHeader#1 Part Produced: ABC123
GroupHeader#2 PartUsed
ProductionNo PartUsed Qty Produced
1 MA111 500
2 MA111 100
3 MA111 200
GroupFooter#2 Total MA123: 800
1 CA222 500
2 CA222 100
3 CA222 200
4 CA222 -100
GroupFooter#2 Total CA222: 700
1 BB333 500
2 BB333 100
3 BB333 200
GroupFooter#2 Total BB333: 800
GroupFooter#1 Total Qty Produced for ABC: 700
I need to get the Summary Qty Produced (GroupFooter#1) for all the ProductionNumbers(1,2,3,4) for that Part Produced (ABC123) which is 700.
(1) What I have done is create a Running Total - distinct count.
(2) I need to identify the maximum value from the distinct count for each PartUsed Group.
(3) Then I need to display the Qty Produced summary for the maximum count. In the above example: Total CC222 has the maximum count = 4 - Qty Produced Sum = 700.
My problem: I cannot figure out the syntax to do (2) and (3).
Would really appreciate some help. Thanks in advance.
~matahari