| From: | Shane Wright <me(at)shanewright(dot)co(dot)uk> |
|---|---|
| To: | pgsql-sql(at)postgresql(dot)org |
| Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Subject: | Re: GROUPing by expressions, and subSELECTs |
| Date: | 2002-03-01 12:18:13 |
| Message-ID: | 200203011218.g21CIFi18470@fullerruss.dsvr.co.uk |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
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(at)shanewright(dot)co(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Dan Langille | 2002-03-01 14:23:32 | Re: Urgent, Many-to-many relationships.....HELP!!!! |
| Previous Message | Marc Polatschek | 2002-03-01 09:54:02 | Re: SQL statement : list table details |