a question on SQL

From: "Tomi N/A" <hefest(at)gmail(dot)com>
To: "pgsql general" <pgsql-general(at)postgresql(dot)org>
Subject: a question on SQL
Date: 2006-12-12 16:47:34
Message-ID: d487eb8e0612120847o5b578122t98ce838cc7ee3690@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Brad Nicholson 2006-12-12 16:49:17 Re: Unrecognized time zone name error.
Previous Message Erik Jones 2006-12-12 16:46:16 Re: date comparisons