I have a Table which I need to report summary information from and to assist with my testing of this I was wondering if it is possible to return summary fields against records in a results set without losing visibility of the detailed records which constitute them?
As an example of what I am trying to achieve; if I have a Table with the following 5 records in it: -
Order No. Part Qty
100 A 1
100 A -1
100 A 1
200 B 20
200 B -15
Is it possible to return all 5 of them with columns for summary values (say for Sum of the Qty against Order & Part and a Count against the whole lot)? i.e. -
Order No. Part Qty Sum of Part Count of Records
100 A 1 1 5
100 A -1 1 5
100 A 1 1 5
200 B 18 3 5
200 B -15 3 5
I can make the summary fields by using GROUP BY but in that case I only get 2 records returned when I want to see all 5.
This is probably quite straight forward but I cannot find anything particularly helpful in BOL.
Many Thanks in advance.
As an example of what I am trying to achieve; if I have a Table with the following 5 records in it: -
Order No. Part Qty
100 A 1
100 A -1
100 A 1
200 B 20
200 B -15
Is it possible to return all 5 of them with columns for summary values (say for Sum of the Qty against Order & Part and a Count against the whole lot)? i.e. -
Order No. Part Qty Sum of Part Count of Records
100 A 1 1 5
100 A -1 1 5
100 A 1 1 5
200 B 18 3 5
200 B -15 3 5
I can make the summary fields by using GROUP BY but in that case I only get 2 records returned when I want to see all 5.
This is probably quite straight forward but I cannot find anything particularly helpful in BOL.
Many Thanks in advance.