X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8E1D4D1B519 for ; Wed, 23 Jun 2004 08:38:31 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 46400-02 for ; Wed, 23 Jun 2004 11:38:33 +0000 (GMT) Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net [194.217.242.85]) by svr1.postgresql.org (Postfix) with ESMTP id 465C6D1B37F for ; Wed, 23 Jun 2004 08:38:26 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-35.mail.demon.net with esmtp (Exim 3.35 #1) id 1Bd65C-000COz-0Z; Wed, 23 Jun 2004 12:38:27 +0100 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id CAFF71594A; Wed, 23 Jun 2004 12:38:25 +0100 (BST) Message-ID: <40D96BB0.7020301@archonet.com> Date: Wed, 23 Jun 2004 12:38:24 +0100 From: Richard Huxton User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) X-Accept-Language: en-us, en MIME-Version: 1.0 To: cristi Cc: pgsql-sql@postgresql.org Subject: Re: sql References: <008601c4590e$f8a391e0$7202a8c0@cristiv> In-Reply-To: <008601c4590e$f8a391e0$7202a8c0@cristiv> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/214 X-Sequence-Number: 18159 cristi wrote: > > I mean: > I want to select the records wich for co1,n1,l1,m1 value are the same and > has the maxim value of the ore field > adding to that value the value of the records which are not selected. SELECT co,clo1,nl,l1,m1,SUM(ore) AS tot_ore FROM xxx WHERE GROUP BY co,clo1,nl,l1,m1 ORDER BY co,clo1,nl,l1,m1; -- Richard Huxton Archonet Ltd