Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8D3704762C6 for ; Fri, 13 Sep 2002 06:34:00 -0400 (EDT) Received: from mx2.mail.ru (mx2.mail.ru [194.67.57.12]) by postgresql.org (Postfix) with ESMTP id A708D4762A4 for ; Fri, 13 Sep 2002 06:33:59 -0400 (EDT) Received: from drweb by mx2.mail.ru with drweb-scanned (Exim MX.2) id 17pnlx-0002fT-00; Fri, 13 Sep 2002 14:34:01 +0400 Received: from [213.128.193.142] (helo=mail.ru) by mx2.mail.ru with esmtp (Exim SMTP.2) id 17pnlw-0002dP-00; Fri, 13 Sep 2002 14:34:00 +0400 Message-ID: <3D81BF17.4030609@mail.ru> Date: Fri, 13 Sep 2002 14:33:59 +0400 From: dima <_pppp@mail.ru> User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.0.0) Gecko/20020816 X-Accept-Language: ru, en-us, en MIME-Version: 1.0 To: Albrecht Berger Cc: pgsql Subject: Re: sql group by statement References: <002f01c25b10$6db4b940$a07ba8c0@wxp> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Envelope-To: berger1517@gmx.ch, pgsql-sql@postgresql.org X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/129 X-Sequence-Number: 9406 see the yesterday's thread about DISTINCT ON (non-standard Postgres feature) > 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.