Re: join problem or maybe group :( - Mailing list pgsql-general

From Tom Lane
Subject Re: join problem or maybe group :(
Date
Msg-id 7597.1030635769@sss.pgh.pa.us
Whole thread Raw
In response to Re: join problem or maybe group :(  ("Ben-Nes Michael" <miki@canaan.co.il>)
List pgsql-general
"Ben-Nes Michael" <miki@canaan.co.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

pgsql-general by date:

Previous
From: Patrick FICHE
Date:
Subject: Re: join problem or maybe group :(
Next
From: Tom Lane
Date:
Subject: Re: Free space mapping (was Re: Multi-Versions and Vacuum)