On Sep 21, 12:09 am, [EMAIL PROTECTED] wrote:
> Write the query (or queries if necessary) needed to count the number
> of employees in each employee's department who are paid more than
> their manager.

SELECT   e.dept, COALESCE (SUM (1), 0) AS n
    FROM employees e JOIN employees m
         ON (e.empid = m.mgrid AND e.salary > m.salary)
GROUP BY e.dept
ORDER BY e.dept


---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

                http://www.postgresql.org/about/donate

Reply via email to