Re: Question about a select

Поиск
Список
Период
Сортировка
От Harald Fuchs
Тема Re: Question about a select
Дата
Msg-id puoefg6tro.fsf@srv.protecting.net
обсуждение исходный текст
Ответ на Question about a select  (Kretschmer Andreas <andreas_kretschmer@despammed.com>)
Список pgsql-sql
In article <20050122155611.GA6592@kaufbach.delug.de>,
Kretschmer Andreas <andreas_kretschmer@despammed.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.



В списке pgsql-sql по дате отправления:

Предыдущее
От: "adam etienne"
Дата:
Сообщение: Re: update from multiple rows
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: returning a record from PL/pgSQL