Received: from mercury.Sun.COM (mercury.Sun.COM [192.9.25.1]) by hub.org (8.8.8/8.7.5) with SMTP id JAA06569 for ; Wed, 12 Aug 1998 09:13:23 -0400 (EDT) Received: from France.Sun.COM ([129.157.188.1]) by mercury.Sun.COM (SMI-8.6/mail.byaddr) with SMTP id GAA19799; Wed, 12 Aug 1998 06:12:33 -0700 Received: from sybille.France.Sun.COM by France.Sun.COM (SMI-8.6/SMI-SVR4-sd.fkk200) id PAA11574; Wed, 12 Aug 1998 15:12:31 +0200 Received: from dimitri by sybille.France.Sun.COM (SMI-8.6/SMI-SVR4) id PAA13216; Wed, 12 Aug 1998 15:12:27 +0200 From: Dimitri Reply-To: dimitri@France.Sun.COM To: Jerome Knobl Subject: Re: [SQL] Subquery problems Date: Wed, 12 Aug 1998 14:59:02 +0200 X-Mailer: KMail [version 0.7.9] Content-Type: text/plain References: <35D14F37.13118C6@mandanet.ch> Cc: pgsql-sql@postgreSQL.org MIME-Version: 1.0 Message-Id: <98081215132106.00535@dimitri> Content-Transfer-Encoding: quoted-printable On Wed, 12 Aug 1998, you wrote: >Hello, > >I'm trying to build some subquery, and it don't works like I want. > >I try the following query : > >select distinct pseudo, (select count(ref) from questions where >questions.refpseudo=3Dpseudos.refold) as xxx from pseudos; You have to try: select pseudo, count(ref) as xxx=20 from pseudos, questions=20 where questions.refpseudo=3Dpseudos.refold group by pseudo; or select pseudo, count(*) as xxx=20 from pseudos, questions=20 where questions.refpseudo=3Dpseudos.refold group by pseudo; This'll be more correct on SQL point and will be more faster to execute because you will avoid duplication in your output... > >That query work well on MSAccess, but I have the following error on ??? M$ SQL is not a good reference... :)) >postgres : > >ERROR: parser: parse error at or near "select" > >I must maybe using an other method. I'm want to optain in a simple query >to list some name of my table pseudos and to see the number of occurency >in the table questions. > >Thank. J=E9r=F4me Kn=F6bl, Switzerland Hope it helps, (dim) -- =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D Dimitri KRAVTCHUK (dim) Sun Microsystems Benchmark Engineer France=20 dimitri@France.Sun.COM =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D