pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: How to do this in PostgreSQL?
2+ messages / 2 participants
[nested] [flat]

* Re: How to do this in PostgreSQL?
@ 2000-04-10 19:50  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Robert Nosko <robertn@eori.net.pl>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2000-04-10 19:50 UTC (permalink / raw)
  To: Robert Nosko <robertn@eori.net.pl>; +Cc: pgsql-sql

"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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* How to do this in PostgreSQL?
@ 2000-04-11 02:38  Robert Nosko <robertn@eori.net.pl>
  0 siblings, 1 reply; 2+ messages in thread

From: Robert Nosko @ 2000-04-11 02:38 UTC (permalink / raw)
  To: pgsql-sql

Hi,

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.
How can I perform it in Postgres?

thanks,
robert



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2000-04-11 02:38 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-04-11 02:38 How to do this in PostgreSQL? Robert Nosko <robertn@eori.net.pl>
2000-04-10 19:50 ` Tom Lane <tgl@sss.pgh.pa.us>

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