Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 018986329C9 for ; Sun, 6 Jun 2010 12:06:20 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 87259-08 for ; Sun, 6 Jun 2010 15:06:12 +0000 (UTC) X-Greylist: delayed 00:07:35.527976 by SQLgrey-1.7.6 Received: from forward13.mail.yandex.net (forward13.mail.yandex.net [95.108.130.120]) by mail.postgresql.org (Postfix) with ESMTP id 2BC2A632187 for ; Sun, 6 Jun 2010 12:06:12 -0300 (ADT) Received: from web135.yandex.ru (web135.yandex.ru [95.108.131.157]) by forward13.mail.yandex.net (Yandex) with ESMTP id CC2701080AAE; Sun, 6 Jun 2010 18:58:35 +0400 (MSD) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1275836315; bh=CmJNQwKhT0luBPPtFCAU7rSXT+2pqxvSlEfBSOqUom0=; h=From:To:Cc:In-Reply-To:References:Subject:MIME-Version:Message-Id: Date:Content-Transfer-Encoding:Content-Type; b=A1B+XA7+p5pzMZrSWE3jAPJpAPI21qEDvqJpDwMYAGwYsD/Q7SmAvyA4cvXxz/C2K 4rWfwiQrJY57ershNvT04MBiCOqg6iWTIvvJjls7XayuJyfkfoHpCJmSvEzo1gEPJy 7SmQhBCoCEn2ZWRpqKHpgursYl0H/3NgYNh5GD9o= Received: from localhost (localhost.localdomain [127.0.0.1]) by web135.yandex.ru (Yandex) with ESMTP id C93CE6B30042; Sun, 6 Jun 2010 18:58:35 +0400 (MSD) X-Yandex-Spam: 1 X-Yandex-Front: web135.yandex.ru X-Yandex-TimeMark: 1275836315 Received: from user-18.81.118.217.in-addr.arpa (user-18.81.118.217.in-addr.arpa [217.118.81.18]) by mail.yandex.ru with HTTP; Sun, 06 Jun 2010 18:58:35 +0400 From: msi77 To: Michele Petrazzo - Unipex Cc: pgsql-sql@postgresql.org In-Reply-To: <4BFD5BC0.90900@unipex.it> References: <4BFD5BC0.90900@unipex.it> Subject: Re: inner join and limit MIME-Version: 1.0 Message-Id: <307921275836315@web135.yandex.ru> Date: Sun, 06 Jun 2010 18:58:35 +0400 X-Mailer: Yamail [ http://yandex.ru ] 5.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=koi8-r X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=4.594 tagged_above=-5 required=5 tests=BAYES_50=0.8, RCVD_HAS_FROM_USER=1.677, RCVD_IN_BL_SPAMCOP_NET=1.347, RCVD_IN_SORBS_WEB=0.77 X-Spam-Level: **** X-Archive-Number: 201006/24 X-Sequence-Number: 34215 Hi, Some ways to do that: http://www.sql-ex.ru/help/select16.php > Hi list, > I have two table that are so represented: > t1: > id int primary key > ... other > t2: > id int primary key > t1id int fk(t1.id) > somedate date > ... other > data t1: > 1 | abcde > 2 | fghi > data t2: > 1 | 1 | 2010-05-23 > 2 | 1 | 2010-05-24 > 3 | 1 | 2010-05-25 > 4 | 2 | 2010-05-22 > 5 | 2 | 2010-05-26 > I'm trying to create a query where the data replied are: > join t1 with t2 and return only the LIMIT 1 (or N) of the t2, with date > order (of t2). > Data should be: > t1.id | t2.id | t2,somedate > 1 | 3 | 2010-05-25 > 2 | 5 | 2010-05-26 > As said, I'm trying, but without success... > Can be done for you? > Thanks, > Michele > Здесь спама нет http://mail.yandex.ru/nospam/sign