Re: SQL query question - Mailing list pgsql-sql

From Rodrigo De León
Subject Re: SQL query question
Date
Msg-id 1191784576.250021.263080@50g2000hsm.googlegroups.com
Whole thread Raw
List pgsql-sql
On Sep 21, 12:09 am, stevenleong...@gmail.com 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



pgsql-sql by date:

Previous
From: Aroon Pahwa
Date:
Subject: valid query runs forever?
Next
From: Dani Castaños
Date:
Subject: Get different sums from the same table in one query