pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Shane Wright <me@shanewright.co.uk>
To: pgsql-sql@postgresql.org
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Subject: Re: GROUPing by expressions, and subSELECTs
Date: Fri, 1 Mar 2002 12:18:13 +0000
Message-ID: <200203011218.g21CIFi18470@fullerruss.dsvr.co.uk> (raw)
In-Reply-To: <14958.1014932420@sss.pgh.pa.us>
References: <200202281830.g1SIU1s11290@fullerruss.dsvr.co.uk>
	<14958.1014932420@sss.pgh.pa.us>


Tom, you're a star!  It took me a minute to work out what you meant, but hte 
whole thing is working a treat now!

Thanks again,

Shane


On Thursday 28 Feb 2002 9:40 pm, Tom Lane wrote:
> Shane Wright <me@shanewright.co.uk> writes:
> > SELECT
> >   [fields],
> >   [expression],
> >   (SELECT * FROM table2 WHERE [expression]) AS mynewfield
> > FROM
> >   table
> > GROUP BY
> >   [expression]
> >
> > But, it gives this error:
> >
> > ERROR: Sub-SELECT uses un-GROUPed attribute [table].[field] from outer
> > query
>
> Yeah, the code is not bright enough to figure out that this could be
> considered legitimate.  But try this:
>
> SELECT
>   [fields],
>   myexpr,
>   (SELECT * FROM table2 WHERE ss.myexpr) AS mynewfield
> FROM
>   (SELECT [fields],
>           [expression] as myexpr
>    FROM table
>    GROUP BY myexpr) AS ss
>
> 			regards, tom lane



view thread (3+ messages)

Message-ID: <200203011218.g21CIFi18470@fullerruss.dsvr.co.uk>
Permalink:  ../200203011218.g21CIFi18470@fullerruss.dsvr.co.uk/
Also on:    postgresql.org/message-id/200203011218.g21CIFi18470@fullerruss.dsvr.co.uk

 · 

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: me@shanewright.co.uk, tgl@sss.pgh.pa.us
  Subject: Re: GROUPing by expressions, and subSELECTs
  In-Reply-To: <200203011218.g21CIFi18470@fullerruss.dsvr.co.uk>

* 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