Re: EXTERN JOIN with WHEN query

From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: javier garcia - CEBAS <rn001(at)cebas(dot)csic(dot)es>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: EXTERN JOIN with WHEN query
Date: 2003-06-06 14:38:59
Message-ID: Pine.LNX.4.33.0306060834500.19717-100000@css120.ihs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 5 Jun 2003, javier garcia - CEBAS wrote:

> Hi all;
> This is a query that I guess is not very difficult, but I'm a newbie;
> I've got a lot of tables, each of them with two columns:
>
> SELECT * FROM precal; ->
> (date) (real)
> fecha | precipitacion
> ------------+---------------
> 1996-01-01 | 0.6
> 1996-02-01 | 0.7
> ...
>
>
> But in this table there are some inexistents records (some missing days)
> And I would like to create lists with a full list of dates and corresponding
> precipitation data, with gaps when the row didn't exist.
> So; I've created a table with a complete series of dates from 1950 up to
> date, and made the query:

Any time you're gonna do this, you can make a table with all the dates in
it already, and left join against that.

I.e. if you want a report for every month, numbered 1 through 12, then
just create a table with an id 1 to 12 and the names of the months. Since
the table's so small, it doesn't even really need indexes.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message scott.marlowe 2003-06-06 14:45:47 Re: Nulls get converted to 0 problem
Previous Message Nigel J. Andrews 2003-06-06 14:09:27 Re: large objects