Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 9B6A82E3997 for ; Fri, 11 Jan 2008 20:10:25 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 56636-10 for ; Fri, 11 Jan 2008 20:10:16 -0400 (AST) Received: from dukecmmtar02.coxmail.com (dukecmmtar02.coxmail.com [68.99.120.49]) by postgresql.org (Postfix) with ESMTP id 565322E3A01 for ; Fri, 11 Jan 2008 20:10:22 -0400 (AST) Received: from [192.168.1.2] (really [70.169.225.166]) by dukecmmtar02.coxmail.com (InterMail vM.6.01.06.01 201-2131-130-101-20060113) with ESMTP id <20080112001021.IREX27127.dukecmmtar02.coxmail.com@[192.168.1.2]> for ; Fri, 11 Jan 2008 19:10:21 -0500 Message-ID: <4788056B.2020809@rakkar.org> Date: Fri, 11 Jan 2008 16:10:19 -0800 From: Kevin Jenkins User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: SQL question: Highest column value of unique column pairs Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/97 X-Sequence-Number: 29950 Hi, I have the following table which holds the result of 1 on 1 matches: FName1, LName1, Score1, FName2, LName2, Score2, Date John, Doe, 85 Bill, Gates, 20 Jan 1. John, Archer, 90 John, Doe, 120 Jan 5 Bob, Barker, 70 Calvin, Klien 8 Jan 8 John, Doe, 60 Bill, Gates, 25 Jan 3. So columns 1 and 2 hold the first person. Column 3 holds his score. Columns 4 and 5 hold the second person. Column 6 holds his score. I want to return the most recent score for each person (be they an opponent or myself). And the resultant table shouldn't care if they are person 1 or 2. So the end result would be FName, LName, Score, Date John, Doe, 120 Jan 5. John, Archer 90 Jan 5. Bob, Barker 70 Jan 8 Bill, Gates 25 Jan 3 Calvin Klien 8 Jan 8 Thanks for any help!