pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedHelp on a sql querry.
2+ messages / 2 participants
[nested] [flat]
* Help on a sql querry.
@ 2001-06-13 09:17 David BOURIAUD <david.bouriaud@ac-rouen.fr>
2001-06-20 17:13 ` Re: Help on a sql querry. Frank Bax <fbax@sympatico.ca>
0 siblings, 1 reply; 2+ messages in thread
From: David BOURIAUD @ 2001-06-13 09:17 UTC (permalink / raw)
To: pgsql-sql
Hi the list !
I've got a table in which I've got informations about persons.
I'd like to know how many there are by etablissements, and the detail by
sex.
So, here is how my table is described :
table can :
num_can //candidate number
nom_can //name
...
cod_sex //sex of candidate : M=Man, F = Woman
...
cod_eta // Etablissemnt where this person is.
Any idea ? I'd like to avoid unions, cause it makes many lines for too
few informations....
Thanks by advance.
--
David BOURIAUD
----------------------------------------------------------
In a world without walls or fences, what use do we have
for windows or gates ?
----------------------------------------------------------
ICQ#102562021
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Help on a sql querry.
2001-06-13 09:17 Help on a sql querry. David BOURIAUD <david.bouriaud@ac-rouen.fr>
@ 2001-06-20 17:13 ` Frank Bax <fbax@sympatico.ca>
0 siblings, 0 replies; 2+ messages in thread
From: Frank Bax @ 2001-06-20 17:13 UTC (permalink / raw)
To: pgsql-sql; +Cc: David BOURIAUD <david.bouriaud@ac-rouen.fr>
You might be looking for something like:
SELECT cod_eta,
SUM (CASE WHEN cod_sex='F' THEN 1 ELSE 0 END) AS female,
SUM (CASE WHEN cod_sex='M' THEN 1 ELSE 0 END) AS male
FROM can
GROUP BY cod_eta
ORDER BY cod_eta;
This should return rows containing: eta, female, male.
I might have made a typo tho...
Frank
At 11:17 AM 6/13/01 +0200, David BOURIAUD wrote:
>Hi the list !
>I've got a table in which I've got informations about persons.
>I'd like to know how many there are by etablissements, and the detail by
>sex.
>So, here is how my table is described :
>table can :
>num_can //candidate number
>nom_can //name
>...
>cod_sex //sex of candidate : M=Man, F = Woman
>...
>cod_eta // Etablissemnt where this person is.
>
>Any idea ? I'd like to avoid unions, cause it makes many lines for too
>few informations....
>Thanks by advance.
>--
>David BOURIAUD
>----------------------------------------------------------
>In a world without walls or fences, what use do we have
>for windows or gates ?
>----------------------------------------------------------
>ICQ#102562021
>
>---------------------------(end of broadcast)---------------------------
>TIP 3: if posting/reading through Usenet, please send an appropriate
>subscribe-nomail command to majordomo@postgresql.org so that your
>message can get through to the mailing list cleanly
>
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-06-20 17:13 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-06-13 09:17 Help on a sql querry. David BOURIAUD <david.bouriaud@ac-rouen.fr>
2001-06-20 17:13 ` Frank Bax <fbax@sympatico.ca>
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