I need to query a table to return a unique set of "sets". The table is structured as follows:
DetailID HeaderID SetID ShiftID Amount
DetailID is the primary key and HeaderID is a foreign key related to the Header Table. The ShiftID is a foreign key to the Shift table. The HeaderID will generally have multiple SetID's. When the ShiftIDs and Amounts are the same with a different SetID I would like to return only one of the SetIDs and the related ShiftIDs and Amounts. As an example:
Header |
Set |
Shift |
Amount |
973 |
1 |
171 |
10 |
973 |
1 |
138 |
2 |
973 |
1 |
157 |
19 |
973 |
1 |
123 |
13 |
973 |
1 |
172 |
5 |
973 |
1 |
153 |
2 |
973 |
1 |
163 |
5 |
973 |
2 |
171 |
9 |
973 |
2 |
138 |
13 |
973 |
2 |
166 |
6 |
973 |
2 |
157 |
12 |
973 |
2 |
143 |
12 |
973 |
2 |
123 |
2 |
973 |
2 |
153 |
1 |
973 |
2 |
168 |
1 |
973 |
3 |
171 |
9 |
973 |
3 |
138 |
13 |
973 |
3 |
166 |
6 |
973 |
3 |
157 |
12 |
973 |
3 |
143 |
12 |
973 |
3 |
123 |
2 |
973 |
3 |
153 |
1 |
973 |
3 |
168 |
1 |
Sets 2 and 3 are identical so I would like to only return sets 1 and 2 or sets 1 and 3 with the table headers showing.
Thank you