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 A5C423A3D71 for ; Sun, 23 Jan 2005 15:38:03 +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 02349-04 for ; Sun, 23 Jan 2005 15:37:52 +0000 (GMT) Received: from main.gmane.org (main.gmane.org [80.91.229.2]) by svr1.postgresql.org (Postfix) with ESMTP id B1F013A528D for ; Sun, 23 Jan 2005 15:37:54 +0000 (GMT) Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1CsjoH-0000R7-00 for ; Sun, 23 Jan 2005 16:37:53 +0100 Received: from srv.protecting.net ([212.126.218.242]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 23 Jan 2005 16:37:53 +0100 Received: from hf0722x by srv.protecting.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 23 Jan 2005 16:37:53 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Harald Fuchs Subject: Re: Question about a select Date: 23 Jan 2005 16:37:47 +0100 Organization: Linux Private Site Lines: 21 Message-ID: References: <20050122155611.GA6592@kaufbach.delug.de> Reply-To: hf1122x@protecting.net Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: srv.protecting.net User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200501/201 X-Sequence-Number: 19989 In article <20050122155611.GA6592@kaufbach.delug.de>, Kretschmer Andreas 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.