X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 163FD54C4C for ; Sat, 12 Mar 2005 18:01:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 97033-04 for ; Sat, 12 Mar 2005 18:00:52 +0000 (GMT) Received: from ns.aprote.ee (ns.aprote.ee [80.235.78.106]) by svr1.postgresql.org (Postfix) with ESMTP id D030E56382 for ; Sat, 12 Mar 2005 18:00:50 +0000 (GMT) Received: Message by Barricade ns.aprote.ee with ESMTP id j2CI1UGJ007015 for ; Sat, 12 Mar 2005 20:01:31 +0200 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.0.6556.0 Subject: Re: Parameterized views proposition Date: Sat, 12 Mar 2005 20:00:48 +0200 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Parameterized views proposition Thread-Index: AcUnH02NbddOi0ajQh6fK+axJvmOQgAC8p3w From: "Tambet Matiisen" To: "Bruno Wolff III" Cc: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.01 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/170 X-Sequence-Number: 20649 >=20 > > Especially if you would like to put a filter on right side of left=20 > > join. Consider this query: > >=20 > > select p.product_id, coalesce(sum(s.amount), 0) > > from product p > > left join sales s on p.product_id =3D s.product_id and s.date = between=20 > > '2005-01-01' and '2005-01-31' group by p.product_id > >=20 > > We would like to have all products listed with sum of their=20 > sales or 0=20 > > if there wasn't any. I haven't figured out so far, how to=20 > write this=20 > > query as view, so that I can set different filters at client side. >=20 > You need to expose the columns you want to filter on so that=20 > they can be used in WHERE clauses. >=20 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).=20 Tambet