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 33E39D1BB91 for ; Wed, 5 Nov 2003 18:30:53 +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 92811-09 for ; Wed, 5 Nov 2003 14:30:23 -0400 (AST) Received: from kuntur.rcp.net.pe (kuntur.rcp.net.pe [200.1.178.4]) by svr1.postgresql.org (Postfix) with ESMTP id 1185FD1BB88 for ; Wed, 5 Nov 2003 14:30:22 -0400 (AST) Received: from wiro.rcp.net.pe ([161.132.8.40] helo=oficina.rcp.net.pe) by kuntur.rcp.net.pe with esmtp (Exim 4.24) id 1AHSQ9-000Gqb-L4 for pgsql-sql@postgresql.org; Wed, 05 Nov 2003 13:30:21 -0500 Received: (1310 bytes) by oficina.rcp.net.pe via sendmail with P:stdio/R:smart_host/T:smtp (sender: ) id for pgsql-sql@postgresql.org; Wed, 5 Nov 2003 13:30:21 -0500 (GMT) (Smail-3.2.0.111 2000-Feb-17 #6 built 2000-Sep-19) To: pgsql-sql@postgresql.org Subject: SQL Help Message-ID: <1068057020.3fa941bce468d@oficina.rcp.net.pe> Date: Wed, 05 Nov 2003 13:30:20 -0500 (GMT) From: luisblock@amauta.rcp.net.pe MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit User-Agent: Oficina Virtual RCP X-Originating-IP: 144.9.158.105 X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=1.0 tagged_above=0.0 required=5.0 tests=ASCII_FORM_ENTRY, BAYES_30, NO_REAL_NAME, USER_AGENT X-Spam-Level: * X-Archive-Number: 200311/72 X-Sequence-Number: 15887 PLS, help, I am trying to JOIN two tables together with the LEFT OUTER JOIN statement, but with a twist: 1. table 1 id and table 2 projectid are the join field 2. Table 1 has de detail info for several ocurrences in table 2. For each id in table 1 (project detail), there are many entries of projectid on table 2 (update log on project) 3. I need a query that gets each project detail (table 1) with ONLY the LAST (most recent) update date and comment (table 2) for that project. The result report will look something like this: Repeat____________________________________________________ PROJECT NAME(table 1) PROJECT DATE(table 1) PROJECT OWNER(table 1) LAST UPDATE(table 2) LAST UPDATE COMMENT(table 2) Repeat_____________________________________________________ I have used the SELECT TOP 1 function, the DISTINCT function, I am out of ideas. Thanx LuisFe