Re: Question about a select

From: Harald Fuchs <hf0722x(at)protecting(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Question about a select
Date: 2005-01-23 15:37:47
Message-ID: puoefg6tro.fsf@srv.protecting.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

In article <20050122155611(dot)GA6592(at)kaufbach(dot)delug(dot)de>,
Kretschmer Andreas <andreas_kretschmer(at)despammed(dot)com> writes:

> Hi,
> I have a table with this columns: machine, date and area.

> Now i need a view with machine an week, calculated from date, and
> sum(area), where date between CURRENT_DATE and now+N days.
> Okay, this is not the problem, it works fine.

> (the original table and the view is more complex)

> The problem is, i need also rows for machine and week with no entrys in
> the table. For this rows the sum(area) shold be NULL ore 0.
> In other words: for every machine i need M rows, and M must be constant.

Week values don't automagically spring into existance when there are
no corresponding entries in your table. Use a set-returning function
for generating the week values you're interested in, and left-join
your table to the SRF.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Klaus W. 2005-01-23 17:23:15 How to update dependent tables AND design considerations
Previous Message adam etienne 2005-01-23 11:36:11 Re: update from multiple rows