pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Nosko <robertn@eori.net.pl>
Cc: pgsql-sql@postgresql.org
Subject: Re: How to do this in PostgreSQL?
Date: Mon, 10 Apr 2000 15:50:27 -0400
Message-ID: <17328.955396227@sss.pgh.pa.us> (raw)
In-Reply-To: <NEBBLMLPILFNHKNECKIFIENOCAAA.robertn@eori.net.pl>
References: <NEBBLMLPILFNHKNECKIFIENOCAAA.robertn@eori.net.pl>

"Robert Nosko" <robertn@eori.net.pl> writes:
> In ORACLE I can perform the following query:

> SELECT tableA.id, title, qty
> FROM tableA, (SELECT id, count(*) qty FROM tableB group by id) tableC
> WHERE tableA.id = tableC.id (+)

> but in PostgreSQL I get error message.

We don't currently have sub-SELECTs in FROM (maybe in 7.1 though).
I doubt we ever will support that nonstandard "(+)" syntax (that's
Oracle-speak for an outer join, no?).

But 7.0 does handle sub-SELECTs in the result list, so you could do

SELECT id, title,
       (SELECT count(*) FROM tableB where tableB.id = tableA.id) AS qty
FROM tableA;

This will be slower than the other way, probably, but it works and is
at least as readable.

			regards, tom lane



view thread (2+ messages)  latest in thread

Message-ID: <17328.955396227@sss.pgh.pa.us>
Permalink:  ../17328.955396227@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/17328.955396227@sss.pgh.pa.us

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, robertn@eori.net.pl
  Subject: Re: How to do this in PostgreSQL?
  In-Reply-To: <17328.955396227@sss.pgh.pa.us>
  References: <NEBBLMLPILFNHKNECKIFIENOCAAA.robertn@eori.net.pl> <17328.955396227@sss.pgh.pa.us>

* 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