X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9A50DD1B531 for ; Wed, 15 Oct 2003 02:13:12 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 30667-06 for ; Tue, 14 Oct 2003 23:12:44 -0300 (ADT) Received: from netspeed-tech.com (unknown [218.104.80.12]) by svr1.postgresql.org (Postfix) with SMTP id 883DBD1B4FC for ; Tue, 14 Oct 2003 23:12:36 -0300 (ADT) Received: (qmail 24403 invoked from network); 15 Oct 2003 02:05:39 -0000 Received: from unknown (HELO aicean) (192.168.0.158) by 0 with SMTP; 15 Oct 2003 02:05:39 -0000 Message-ID: <003401c392c1$86c75660$9e00a8c0@aicean> From: "aicean" To: Subject: How can I produce the following desired result? Date: Wed, 15 Oct 2003 10:09:11 +0800 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_002F_01C39304.60D63870" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.4 tagged_above=0.0 required=5.0 tests=HTML_50_60, HTML_FONT_FACE_ODD X-Spam-Level: X-Archive-Number: 200310/167 X-Sequence-Number: 15567 This is a multi-part message in MIME format. ------=_NextPart_000_002F_01C39304.60D63870 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable How can I produce the following desired result? goodid totalnum operationdate storehistoryid=20 132 35.000 09-28-2003 66=20 135 11.500 09-28-2003 61=20 132 35.000 09-27-2003 60=20 135 11.000 09-28-2003 59=20 135 12.000 09-28-2003 58=20 134 100.000 09-28-2003 57=20 134 112.000 09-27-2003 56=20 131 0.000 09-26-2003 54=20 131 33.000 09-26-2003 51=20 131 -2.000 09-26-2003 50=20 3 550.000 09-26-2003 49=20 3 52.000 09-26-2003 48=20 132 35.000 09-27-2003 42=20 3 124.000 09-25-2003 41=20 131 59.000 09-25-2003 40=20 132 57.000 09-26-2003 39=20 131 2.000 09-24-2003 38=20 3 2.000 09-20-2003 23=20 =20=20=20=20=20=20 result: goodid totalnum operationdate storehistoryid=20 132 35.000 09-28-2003 66=20 135 11.500 09-28-2003 61=20=20=20=20=20=20 134 100.000 09-28-2003 57=20 131 0.000 09-26-2003 54=20 3 550.000 09-26-2003 49=20=20=20=20=20=20= =20=20=20=20 I need to select rows which storehistoryid is max as the same goodid . Thanks in advance aicean Mailto:aicean@netspeed-tech.com ------=_NextPart_000_002F_01C39304.60D63870 Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: quoted-printable
How can I produce the following desired= =20 result?
 
   =20 goodid        totalnum  =20 operationdate storehistoryid
      =20 132         =20 35.000     =20 09-28-2003           = ; =20 66
      =20 135         =20 11.500     =20 09-28-2003           = ; =20 61
      =20 132         =20 35.000     =20 09-27-2003           = ; =20 60
      =20 135         =20 11.000     =20 09-28-2003           = ; =20 59
      =20 135         =20 12.000     =20 09-28-2003           = ; =20 58
      =20 134        =20 100.000     =20 09-28-2003           = ; =20 57
      =20 134        =20 112.000     =20 09-27-2003           = ; =20 56
      =20 131          =20 0.000     =20 09-26-2003           = ; =20 54
      =20 131         =20 33.000     =20 09-26-2003           = ; =20 51
      =20 131         =20 -2.000     =20 09-26-2003           = ; =20 50
        =20 3        =20 550.000     =20 09-26-2003           = ; =20 49
        =20 3         =20 52.000     =20 09-26-2003           = ; =20 48
      =20 132         =20 35.000     =20 09-27-2003           = ; =20 42
        =20 3        =20 124.000     =20 09-25-2003           = ; =20 41
      =20 131         =20 59.000     =20 09-25-2003           = ; =20 40
      =20 132         =20 57.000     =20 09-26-2003           = ; =20 39
      =20 131          =20 2.000     =20 09-24-2003           = ; =20 38 
         =20 3          =20 2.000     =20 09-20-2003           = ; =20 23 
     
result:
   =20 goodid        totalnum  =20 operationdate storehistoryid
      =20 132         =20 35.000     =20 09-28-2003           = ; =20 66
      =20 135         =20 11.500     =20 09-28-2003           = ; =20 61      
     &nb= sp;=20 134        =20 100.000     =20 09-28-2003           = ; =20 57 
       131   =        =20 0.000     =20 09-26-2003           = ; =20 54 
       =20  3        =20 550.000     =20 09-26-2003           = ; =20 49          
 
I need   to select rows which=20 storehistoryid is max as the same goodid .
 
 
Thanks  in advance
 
 
 aicean
 Mailto:aicean@netspeed-tech.com
------=_NextPart_000_002F_01C39304.60D63870--