gudii9
asked on
max query
SELECT Professor_Name , Department , Salary FROM SALARIES GROUP BY (Department ) ORDER BY MAX (Salary ) DESC LIMIT 1
how above different from below
SELECT Professor_Name , Department , Max(Salary) FROM SALARIES GROUP BY (Department )
i above query returning only one department instead i need highest salaries of each department. how to fix it
please advise
how above different from below
SELECT Professor_Name , Department , Max(Salary) FROM SALARIES GROUP BY (Department )
i above query returning only one department instead i need highest salaries of each department. how to fix it
please advise
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Given that both queries are syntactically incorrect, I would say nothing. Neither of those queries run, at least they don't run in my Oracle test database. To get them to run, you would have to add all the columns that are not aggregated to the group by clause.
The first one would have to be
select Professor_Name , Department , Salary FROM SALARIES GROUP BY (Department, professor_name, salary ) ORDER BY MAX (Salary )
and the second one would have to be
SELECT Professor_Name , Department , Max(Salary) FROM SALARIES GROUP BY (Department, professor_name )
Can you tell us what you are trying to accomplish, then maybe we can help you get you where you want to go.
The first one would have to be
select Professor_Name , Department , Salary FROM SALARIES GROUP BY (Department, professor_name, salary ) ORDER BY MAX (Salary )
and the second one would have to be
SELECT Professor_Name , Department , Max(Salary) FROM SALARIES GROUP BY (Department, professor_name )
Can you tell us what you are trying to accomplish, then maybe we can help you get you where you want to go.
ASKER
how above different from below?
SELECT Professor_Name , Department , Max(Salary) FROM SALARIES GROUP BY (Department )