My table is as below
WORKS ( emp-name, comp-name, salary)
I want to find the comp-name which pays to lowest total salary to it's employees
I tries below query, but it gives SUM of salaries for all comp-name
SELECT comp-name, MIN(sal) as lowest
FROM
(
SELECT comp-name, SUM(salary) as sal from WORKS group by comp-name
)tmt group by comp-name;
How do I find only one company which pays lowest total salary.
select c,min(s) from words group by c