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 C5E57D1CE3E for ; Mon, 2 Feb 2004 15:21:11 +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 43674-04 for ; Mon, 2 Feb 2004 11:21:13 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 07CFFD1B4D2 for ; Mon, 2 Feb 2004 11:21:09 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i12FL8sv076972 for ; Mon, 2 Feb 2004 15:21:08 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i12FA06U074769 for pgsql-sql@postgresql.org; Mon, 2 Feb 2004 15:10:00 GMT From: pawel@deso.pl (Paul Czubilinski) X-Newsgroups: comp.databases.postgresql.sql Subject: SQL query Date: 2 Feb 2004 07:10:04 -0800 Organization: http://groups.google.com Lines: 30 Message-ID: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: groups-abuse@google.com To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/39 X-Sequence-Number: 16730 Hello, I would like to retrieve all the records from table A which have given lang_id and its modification date is later then modification date of the same id record with lang_id='pl'. Example: table A - data example ====================== id | modification_date | lang_id --------+---------------------+------ abc | 2002-10-11 10:12:11 | en abc | 2002-11-12 11:12:11 | pl abc | 2002-11-11 18:12:00 | de sample | 2003-04-15 22:43:14 | pl sample | 2003-05-16 11:10:15 | en sample | 2003-11-11 18:11:10 | de If given lang_id would be 'en' the following record should be choosed: sample | 2003-05-16 11:10:15 | en (it has mofication date later then record with id = sample and lang_id = pl) If you have any idea how to make SQL query for this, please help me. Thanx, Paul Czubilinski