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 A041C53402 for ; Tue, 12 Apr 2005 14:25:26 -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 72628-04 for ; Tue, 12 Apr 2005 17:25:18 +0000 (GMT) Received: from laker.lake-lotawana.mo.us (anubis.duboislc.org [206.114.195.111]) by svr1.postgresql.org (Postfix) with ESMTP id AE2EB533F1 for ; Tue, 12 Apr 2005 14:25:16 -0300 (ADT) Received: from [192.168.1.2] (pcp0011972217pcs.indpnd01.mo.comcast.net [69.247.198.159]) by laker.lake-lotawana.mo.us (8.12.8/8.12.8) with ESMTP id j3CHOiE4002488 for ; Tue, 12 Apr 2005 12:25:15 -0500 Message-ID: <425C0445.8020603@lake-lotawana.mo.us> Date: Tue, 12 Apr 2005 12:24:21 -0500 From: "A. R. Van Hook" User-Agent: Mozilla Thunderbird 0.8 (X11/20041020) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: max question Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200504/174 X-Sequence-Number: 21067 I have the following in a table: oid | citkey | contby | contdate | abcontinue | ccdate ---------+------------+----------+------------+------------+------------ 5774835 | 04-0594703 | | | | 5775325 | 04-0594703 | Attorney | 04/06/2005 | 6 | 03/07/2005 5776060 | 04-0594703 | Attorney | 05/04/2005 | 6 | 04/05/2005 5776067 | 04-0594703 | Attorney | 05/04/2005 | 6 | 04/05/2005 I am trying to pull rows that have the max. contdate. Why does the following give more than 2 rows? ql "select oid,* from ccontinue where citkey ='04-0594703' group by oid,citkey,contby,contdate,abcontinue,ccdate having max(contdate) = contdate" oid | citkey | contby | contdate | abcontinue | ccdate ---------+------------+----------+------------+------------+------------ 5776067 | 04-0594703 | Attorney | 05/04/2005 | 6 | 04/05/2005 5775325 | 04-0594703 | Attorney | 04/06/2005 | 6 | 03/07/2005 5776060 | 04-0594703 | Attorney | 05/04/2005 | 6 | 04/05/2005 (3 rows) thanks