Re: Find "smallest common year"

From: Carlos Moreno <moreno_pg(at)mochima(dot)com>
To:
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Find "smallest common year"
Date: 2007-09-27 12:17:41
Message-ID: 46FB9F65.9070507@mochima.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Stefan Schwarzer wrote:
> Sorry,
>
> I forgot to mention my table design, which is like this:
>
> name 2001 2002 2003 2004 2005
> -----------------------------------------------------------------
> Afghanistan ....
> Albania ....
>
> (Yep, I know, bad table design.... :-)). I tried to change it to the
> more common "id | year | value" format, but there were too many SQL
> problems afterwards for the different queries/calculations we need to
> have....)

May I suggest that you concentrate on solving *those* problems instead of
the programmatically trivial computation of lowest common value? Notice
that a *really trivial* programming exercise becomes highly involved in
your case --- if I'm understanding correctly what you have, I assume you'd
have to check one by one the fields for NULL or non-NULL values --- that's
intolerably ugly, IMHO, and it is a very simple and direct consequence of
an as-unsound-as-it-gets db/table design.

Carlos
--

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jan de Visser 2007-09-27 12:37:18 Re: pg_dump (8.1.9) does not output copy statements
Previous Message Stefan Schwarzer 2007-09-27 12:07:12 Re: Find "smallest common year"