Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 16DA84762A4 for ; Fri, 13 Sep 2002 06:39:01 -0400 (EDT) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by postgresql.org (Postfix) with SMTP id 02AE34760BB for ; Fri, 13 Sep 2002 06:39:00 -0400 (EDT) Received: (qmail 29545 invoked by uid 0); 13 Sep 2002 10:39:02 -0000 Received: from pd9e6d96a.dip.t-dialin.net (HELO wxp) (217.230.217.106) by mail.gmx.net (mp017-rz3) with SMTP; 13 Sep 2002 10:39:01 -0000 Message-ID: <006501c25b11$e30914b0$a07ba8c0@wxp> From: "Albrecht Berger" To: "pgsql" References: <002f01c25b10$6db4b940$a07ba8c0@wxp> <3D81BF17.4030609@mail.ru> Subject: Re: sql group by statement Date: Fri, 13 Sep 2002 12:39:46 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/130 X-Sequence-Number: 9407 but how do I know that "distinct on" doesn't cut off the row with max(val2) of that id that I need ? > 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. > > >