Received: from tomts5-srv.bellnexxia.net (tomts5.bellnexxia.net [209.226.175.25]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f5KHEja07822 for ; Wed, 20 Jun 2001 13:14:45 -0400 (EDT) (envelope-from fbax@sympatico.ca) Received: from acer ([64.228.130.26]) by tomts5-srv.bellnexxia.net (InterMail vM.4.01.03.16 201-229-121-116-20010115) with SMTP id <20010620171444.TRLV17517.tomts5-srv.bellnexxia.net@acer>; Wed, 20 Jun 2001 13:14:44 -0400 Message-Id: <3.0.6.32.20010620131300.0239c760@pop6.sympatico.ca> X-Sender: b1wudu74@pop6.sympatico.ca X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.6 (32) Date: Wed, 20 Jun 2001 13:13:00 -0400 To: "pgsql-sql@postgresql.org" From: Frank Bax Subject: Re: Help on a sql querry. Cc: David BOURIAUD In-Reply-To: <3B272F9A.C8089ED6@ac-rouen.fr> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Archive-Number: 200106/312 X-Sequence-Number: 3597 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 >