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 3F197D1B191 for ; Wed, 23 Jun 2004 07:44:24 -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 18307-02 for ; Wed, 23 Jun 2004 10:44:17 +0000 (GMT) Received: from mail.dmhi.ct.ro (dmhi.ct.ro [193.226.151.66]) by svr1.postgresql.org (Postfix) with ESMTP id 6605ED1B169 for ; Wed, 23 Jun 2004 07:44:13 -0300 (ADT) Received: from cristiv ([192.168.2.114]) by mail.dmhi.ct.ro (8.12.8/8.12.8) with SMTP id i5NAk6R0012697 for ; Wed, 23 Jun 2004 13:46:07 +0300 Message-ID: <008601c4590e$f8a391e0$7202a8c0@cristiv> From: "cristi" To: Subject: sql Date: Wed, 23 Jun 2004 13:43:50 +0300 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.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=LINES_OF_YELLING, LINES_OF_YELLING_2 X-Spam-Level: X-Archive-Number: 200406/212 X-Sequence-Number: 18157 I have the following table structure: CREATE TABLE "xxx" ( "co" character varying(7), "co1" character varying(9), "n1" character varying(15), "l1" character varying(5), "m1" smallint, "ore" bigint ); who contains the following date: 22021CC 1044 637 S5G8 407 5 22021CC 1044 637 S5G8 409 47 22021CD 1044 637 S5G8 410 24 22022BB 1044 637 S5G8 409 10 I need a SQL select which result to be: 22021CC 1044 637 S5G8 407 5 22021CC 1044 637 S5G8 409 57 22021CD 1044 637 S5G8 410 24 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. Wou! Thanks in advance!