Hi
Suppose I have a table that looks something like this
Name Dep Salary
-----------------------
Mark IT 40
Jim Sales 50
Jon IT 60
Sue Sales 70
I want to select the name of the person with the maximum salary in each department, their salary and the department they work for, ie
Name Dep Max(Salary)
-----------------------
Jon IT 60
Sue Sales 70
This does not work
Select Name, Max(Salary), Dep from Table Group by Dep;
because it produces the error "not a group by expression"
And neither does this
Select Name, Max(Salary), Dep from Table Group by Dep, Name;
because it basically returns the whole table
I can't find any help on this
Surely it is not that difficult?
Thanks
Mark
Suppose I have a table that looks something like this
Name Dep Salary
-----------------------
Mark IT 40
Jim Sales 50
Jon IT 60
Sue Sales 70
I want to select the name of the person with the maximum salary in each department, their salary and the department they work for, ie
Name Dep Max(Salary)
-----------------------
Jon IT 60
Sue Sales 70
This does not work
Select Name, Max(Salary), Dep from Table Group by Dep;
because it produces the error "not a group by expression"
And neither does this
Select Name, Max(Salary), Dep from Table Group by Dep, Name;
because it basically returns the whole table
I can't find any help on this
Surely it is not that difficult?
Thanks
Mark