From: | "Dinesh Pandey" <dpandey(at)secf(dot)com> |
---|---|
To: | "'A(dot) R(dot) Van Hook'" <hook(at)lake-lotawana(dot)mo(dot)us>, <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: max question |
Date: | 2005-04-13 05:02:39 |
Message-ID: | 20050413050528.1C639533A8@svr1.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Try
"select oid,* from ccontinue where citkey ='04-0594703' group by
oid,citkey,contby,contdate,abcontinue,ccdate having contdate= max(contdate)"
Thanks
Dinesh Pandey
-----Original Message-----
From: pgsql-sql-owner(at)postgresql(dot)org [mailto:pgsql-sql-owner(at)postgresql(dot)org]
On Behalf Of A. R. Van Hook
Sent: Tuesday, April 12, 2005 10:54 PM
To: pgsql-sql(at)postgresql(dot)org
Subject: [SQL] max question
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
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
From | Date | Subject | |
---|---|---|---|
Next Message | Bill Lawrence | 2005-04-13 06:08:05 | Re: Getting the output of a function used in a where clause |
Previous Message | Dinesh Pandey | 2005-04-13 04:58:44 | Re: ignore single character in SELECT query? |