a question on SQL - Mailing list pgsql-general

From Tomi N/A
Subject a question on SQL
Date
Msg-id d487eb8e0612120847o5b578122t98ce838cc7ee3690@mail.gmail.com
Whole thread Raw
Responses Re: a question on SQL  (Ragnar <gnari@hive.is>)
List pgsql-general
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?

I'm perplexed by the simplicity of the task and the fact that what
solutions I did come up with fail to perform very well (a subselect
with ORDER BY MIN(production_date) LIMIT 1) or are rather complex
(using temp tables).

Hints?

TIA,
t.n.a.

pgsql-general by date:

Previous
From: Erik Jones
Date:
Subject: Re: date comparisons
Next
From: Brad Nicholson
Date:
Subject: Re: Unrecognized time zone name error.