Re: Find "smallest common year" - Mailing list pgsql-general

From Carlos Moreno
Subject Re: Find "smallest common year"
Date
Msg-id 46FB9F65.9070507@mochima.com
Whole thread Raw
In response to Re: Find "smallest common year"  (Stefan Schwarzer <stefan.schwarzer@grid.unep.ch>)
List 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
--


pgsql-general by date:

Previous
From: Stefan Schwarzer
Date:
Subject: Re: Find "smallest common year"
Next
From: Jan de Visser
Date:
Subject: Re: pg_dump (8.1.9) does not output copy statements