> 
> > 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

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

               http://archives.postgresql.org

Reply via email to