pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Patrick JACQUOT <patrick.jacquot@anpe.fr>
To: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] SubSelect as a column
Date: Tue, 08 Feb 2000 10:19:23 +0100
Message-ID: <389FDF9A.8596E7C1@anpe.fr> (raw)
References: <Pine.BSF.4.10.10002071642050.53230-100000@maximillion.sscsinc.com>
	<27709.949980829@sss.pgh.pa.us>

Tom Lane wrote:

> Lars <lars@sscsinc.com> writes:
> > I am trying to use a subselect as a column name, but it appears as if this
> > is not supported in Postgresql. Here is the query:
>
> > SELECT u.idnum, u.username,
> >   (SELECT COUNT(t.techid)
> >    FROM ticket t
> >    WHERE t.techid = u.idnum)
> > FROM users u;
>
> Nope, doesn't work in 6.5.*.  It is there in current sources for the
> upcoming 7.0 release.  Can't think of any good workaround in 6.5...
>
>                         regards, tom lane
>
> ************

i would do an UNION  of the tuples coming from the joint
with the tuples from "users" who don't have a counterpart in "ticket",
using "not exists" and adding to them a zero count.
Hoping it will help
regards
P.Jacquot




view thread (5+ messages)  latest in thread

Message-ID: <389FDF9A.8596E7C1@anpe.fr>
Permalink:  ../389FDF9A.8596E7C1@anpe.fr/
Also on:    postgresql.org/message-id/389FDF9A.8596E7C1@anpe.fr

 · 

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: patrick.jacquot@anpe.fr
  Subject: Re: [SQL] SubSelect as a column
  In-Reply-To: <389FDF9A.8596E7C1@anpe.fr>
  References: <Pine.BSF.4.10.10002071642050.53230-100000@maximillion.sscsinc.com> <27709.949980829@sss.pgh.pa.us> <389FDF9A.8596E7C1@anpe.fr>

* 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