I am having trouble figuring out how to
group by only a subset of the fields in a SELECT
statement.
Given this table:
PersonID Dept EmplType Location Bonus
1 IT Manager A 10,000
5 HR Admin B 20,000
9 HR Manager B 20,000
11 IT Analyst A 10,000
14 IT Analyst C 10,000
I want to be able to select all 5 columns in my query.
I want to limit the output to include only the Manager rows...however,
I would like to sum the Bonus by Department and report
this with the rest of the manager row.
The expected output would be
1 IT Manager A 30,000
9 HR Manager B 40,000
I've kind of simplified what I really need to do,
but if I can get some direction on this, I think
I can apply it to my real world query.
Thanks,
Danno
group by only a subset of the fields in a SELECT
statement.
Given this table:
PersonID Dept EmplType Location Bonus
1 IT Manager A 10,000
5 HR Admin B 20,000
9 HR Manager B 20,000
11 IT Analyst A 10,000
14 IT Analyst C 10,000
I want to be able to select all 5 columns in my query.
I want to limit the output to include only the Manager rows...however,
I would like to sum the Bonus by Department and report
this with the rest of the manager row.
The expected output would be
1 IT Manager A 30,000
9 HR Manager B 40,000
I've kind of simplified what I really need to do,
but if I can get some direction on this, I think
I can apply it to my real world query.
Thanks,
Danno