sql group by statement - Mailing list pgsql-sql

From Albrecht Berger
Subject sql group by statement
Date
Msg-id 002f01c25b10$6db4b940$a07ba8c0@wxp
Whole thread Raw
Responses Re: sql group by statement
List pgsql-sql
Hello,
I have a problem, which I'm not able to solve with a simple query :

I need a resultset with distinct id's, but the max val2 of each id.
I tried to group by id, but though I need the pk in my resultset
I have to group it too, which "destroys" the group of val2.

Can this be done without a huge query ?

Table :
pk   id   val1 val21    1    2   32    1    2   43    2    1   14    1    0   55    2    1   8

Needed Result :
pk   id   val1 val24    1    0   55    2    1   8

Thx
berger




pgsql-sql by date:

Previous
From: "Christopher Kings-Lynne"
Date:
Subject: Re: DISTINCT ON
Next
From: dima
Date:
Subject: Re: sql group by statement