pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dimitri <dimitri@France.Sun.COM>
To: Jerome Knobl <jknobl@mandanet.ch>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Subquery problems
Date: Wed, 12 Aug 1998 14:59:02 +0200
Message-ID: <98081215132106.00535@dimitri> (raw)
References: <35D14F37.13118C6@mandanet.ch>

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=pseudos.refold) as xxx from pseudos;

You have to try:

select pseudo,  count(ref) as xxx 
  from pseudos, questions 
  where questions.refpseudo=pseudos.refold
  group by pseudo;

or

select pseudo,  count(*) as xxx 
  from pseudos, questions 
  where questions.refpseudo=pseudos.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érôme Knöbl, Switzerland

Hope it helps,
(dim)


--
=====================================================
 Dimitri KRAVTCHUK  (dim)           Sun Microsystems
 Benchmark Engineer                 France 
 dimitri@France.Sun.COM
=====================================================



view thread (9+ messages)  latest in thread

Message-ID: <98081215132106.00535@dimitri>
Permalink:  ../98081215132106.00535@dimitri/
Also on:    postgresql.org/message-id/98081215132106.00535@dimitri

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dimitri@France.Sun.COM, jknobl@mandanet.ch
  Subject: Re: [SQL] Subquery problems
  In-Reply-To: <98081215132106.00535@dimitri>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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