Re: [QUESTION] SQL*Plus: Joins

From: Kevin Loney <"75663,327"_at_compuserve.com>
Date: 1996/10/09
Message-ID: <325BCA03.3B5A_at_compuserve.com>#1/1


Frampton Steve R wrote:
>
> What is the proper way of doing something like this:
>
> select count(a.employee_id) male, count(b.employee_id) female
> from employee_table a, employee_table b
> where a.gender = 'M'
> and b.gender = 'F';
>

Two ways:
As two records in one query:
select gender, count(*) from employee_table group by gender;

As two columns in one row of one query:
select sum(decode(gender,'M',1,0)) Males, sum(decode(gender,'F',1,0)) females from employee_table;

-Kevin Received on Wed Oct 09 1996 - 00:00:00 CEST

Original text of this message