I need to fill up a sparse table in an view

From: Andreas <maps(dot)on(at)gmx(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: I need to fill up a sparse table in an view
Date: 2013-03-02 19:30:50
Message-ID: 5132536A.50508@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

I need to fill up a sparse table in an view.
The table holds some numbers relating months and objects.
The month is an integer in the format YYYYMM.

To make it more convenient to manage this table I decidet to let a value
be good till the next entry.
E.g. if there is an entry in january and march, the january entry is
good in february, too.

So the table looks like.
my_numbers ( object_id int, month int, some_nr int )

( 17, 201301, 123 ),
( 42, 201301, 456 ),
( 42, 201303, 789 ),

Now I need a view that fills the gaps up till the current month.

( 17, 201301, 123 ),
( 17, 201302, 123 ), <-- filled gap
( 17, 201303, 123 ), <-- filled gap
( 42, 201301, 456 ),
( 42, 201302, 456 ), <-- filled gap
( 42, 201303, 789 ),

Is this possible?

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Victor Yegorov 2013-03-02 20:46:18 Re: I need to fill up a sparse table in an view
Previous Message Wayne Cuddy 2013-03-02 18:20:05 Re: Need help revoking access WHERE state = 'deleted'