max question

From: "A(dot) R(dot) Van Hook" <hook(at)lake-lotawana(dot)mo(dot)us>
To: pgsql-sql(at)postgresql(dot)org
Subject: max question
Date: 2005-04-12 17:24:21
Message-ID: 425C0445.8020603@lake-lotawana.mo.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message PFC 2005-04-12 18:34:36 Re: pg 8.0.1-r3 killls pgadmin3 and phppgadmin
Previous Message Carlos Moreno 2005-04-12 15:47:54 Re: Update aborted if trigger function fails?