On 3 October 2011 08:33, Alexander Pyhalov wrote:
> Now we want to select count of all employees who doesn't have any
> subordinates (query 1):
> SELECT count(employee_id) from employees o where not exists (select 1 from
> employees where manager_id=o.employee_id);
> count
> ---
> 89
>
On Mon, Oct 03, 2011 at 11:48:45AM +0400, Alexander Pyhalov wrote:
> On 10/03/2011 11:19, Achilleas Mantzios wrote:
> >Alexander, that's a classic one,
> >rewrite your last query as :
> >
> >SELECT count(employee_id) from employees where employee_id not in
> > (select manager_id from employees
On 10/03/2011 11:19, Achilleas Mantzios wrote:
Alexander, that's a classic one,
rewrite your last query as :
SELECT count(employee_id) from employees where employee_id not in
(select manager_id from employees WHERE manager_id IS NOT NULL);
NULLS semantics are sometimes not so obvious.
Alexander, that's a classic one,
rewrite your last query as :
SELECT count(employee_id) from employees where employee_id not in
(select manager_id from employees WHERE manager_id IS NOT NULL);
NULLS semantics are sometimes not so obvious.
Στις Monday 03 October 2011 09:33:12 ο/η Alexan
Hello.
I was asked a simple question. We have table employees:
\d employees
Table "public.employees"
Column |Type |
Modifiers
+-+-