| От | Ragnar |
|---|---|
| Тема | Re: a question on SQL |
| Дата | |
| Msg-id | 1165943627.6369.49.camel@localhost.localdomain обсуждение исходный текст |
| Ответ на | a question on SQL ("Tomi N/A" <hefest@gmail.com>) |
| Список | pgsql-general |
On þri, 2006-12-12 at 16:47 +0000, Tomi N/A wrote:
> Don't really know where to ask this...the general mailing list sounds
> like the closest.
>
> Let's say I have three tables: owner, factory and product with a 1:N
> relationship at each step.
> Assuming that a product has a production date, how would you go about
> returning a factory for every owner, where the returned factory is the
> factory that produced the oldest product of it's owner?
> Hints?
someting like this maybe:
select distinct on (owner.id,factory.factoryid) *
from owner,factory,product
where <your join contitions>
order by owner.id,factory.factoryid,production_date
gnari
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера