Re: Parameterized views proposition - Mailing list pgsql-sql

From Tambet Matiisen
Subject Re: Parameterized views proposition
Date
Msg-id A66A11DBF5525341AEF6B8DE39CDE77008804F@black.aprote.com
Whole thread Raw
In response to Parameterized views proposition  ("Tambet Matiisen" <t.matiisen@aprote.ee>)
List pgsql-sql
>
> > Especially if you would like to put a filter on right side of left
> > join. Consider this query:
> >
> > select p.product_id, coalesce(sum(s.amount), 0)
> > from product p
> > left join sales s on p.product_id = s.product_id and s.date between
> > '2005-01-01' and '2005-01-31' group by p.product_id
> >
> > We would like to have all products listed with sum of their
> sales or 0
> > if there wasn't any. I haven't figured out so far, how to
> write this
> > query as view, so that I can set different filters at client side.
>
> You need to expose the columns you want to filter on so that
> they can be used in WHERE clauses.
>

Exposing columns won't solve my problem. See the previous query -
sales.date ise grouped out and can't be exposed (note that I want all
products listed, regardless if there were sales in this period or not).
 Tambet


pgsql-sql by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: Parameterized views proposition
Next
From: Andrew - Supernews
Date:
Subject: Re: Parameterized views proposition