On Tue, 2006-06-06 at 16:17, Aaron Bono wrote:
> Though there may be a more eligant way to do it, when we did things
> like this in the past we created a function (or stored procedure) that
> got the min and max dates and then created a result set that iterated
> through the dates to create a virtual table of days. Then you can
> inner join that list of days with your physical table.
If you're on a version of pgsql with generate_series, you can use that
to easily create a pivoting data set on the fly to do this.
If you're on an older version, it's easy enough to make a generic pivot
table and keep it around to do these things. Since we're still on 7.4
where I work, we use the pre-populated pivot table. It's primitive, but
it works.