From: Rodrigo De León <rdeleonp@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: SQL query question
Date: Sun, 07 Oct 2007 19:16:16 -0000
Message-ID: <1191784576.250021.263080@50g2000hsm.googlegroups.com> (raw)
In-Reply-To: <1190351385.027308.79280@t8g2000prg.googlegroups.com>
References: <1190351385.027308.79280@t8g2000prg.googlegroups.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: rdeleonp@gmail.com
Subject: Re: SQL query question
In-Reply-To: <1191784576.250021.263080@50g2000hsm.googlegroups.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox