Re: inner join and limit

From: msi77 <msi77(at)yandex(dot)ru>
To: Michele Petrazzo - Unipex <michele(dot)petrazzo(at)unipex(dot)it>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: inner join and limit
Date: 2010-06-06 14:58:35
Message-ID: 307921275836315@web135.yandex.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Little, Douglas 2010-06-06 15:15:52 Re: [SQL] Difference between these two queries ?
Previous Message Sergey Konoplev 2010-06-06 09:04:33 Re: [SQL] Difference between these two queries ?