Re: join problem or maybe group :(

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Ben-Nes Michael" <miki(at)canaan(dot)co(dot)il>
Cc: "Stephan Szabo" <sszabo(at)megazone23(dot)bigpanda(dot)com>, "postgres" <pgsql-general(at)postgresql(dot)org>
Subject: Re: join problem or maybe group :(
Date: 2002-08-29 15:42:49
Message-ID: 7597.1030635769@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Ben-Nes Michael" <miki(at)canaan(dot)co(dot)il> writes:
> Just wonder, how can i do:
> select max(column1), column2 from table;
> its saying:
> ERROR: Attribute table.column2 must be GROUPed or used in an aggregate
> function
> and all i want is that column2 value will be the mate fo column1 max?

You want DISTINCT ON ... see the weather-reports example on the SELECT
man page.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Patrick FICHE 2002-08-29 15:42:55 Re: join problem or maybe group :(
Previous Message Greg Patnude 2002-08-29 15:35:42 Why must the function that a trigger calls return "opaque" ???