From: Tom Lane <tgl@sss.pgh.pa.us>
To: me@shanewright.co.uk
Cc: pgsql-sql@postgresql.org
Subject: Re: GROUPing by expressions, and subSELECTs
Date: Thu, 28 Feb 2002 16:40:20 -0500
Message-ID: <14958.1014932420@sss.pgh.pa.us> (raw)
In-Reply-To: <200202281830.g1SIU1s11290@fullerruss.dsvr.co.uk>
References: <200202281830.g1SIU1s11290@fullerruss.dsvr.co.uk>
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
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: tgl@sss.pgh.pa.us, me@shanewright.co.uk
Subject: Re: GROUPing by expressions, and subSELECTs
In-Reply-To: <14958.1014932420@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