Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Harry Tuttle Newsgroups: comp.databases.postgresql Subject: Re: Returning a table in SQL Date: Tue, 26 Aug 2014 23:34:16 +0200 Lines: 27 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net U3mN86tB9s17/DCZZ96O/gWBabVsGyJVrhCBxh4X+stOa1frg= Cancel-Lock: sha1:SxKtRyS8W78vMqkUnIsy8G2Z8qU= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.5.666 In-Reply-To: Xref: csiph.com comp.databases.postgresql:590 Robert Klemme wrote on 26.08.2014 22:28: >> with report as ( >> select * >> fromsome_report('Customer','2014-08-01','2014-08-08') >> ) >> select * >> from report > > I guess there is a space missing between "from" and "some_report". Yes, of course. Copy & Paste error. > It seems a simpler variant would be > > select * > from some_report('Customer','2014-08-01','2014-08-08') > > Or does that not work? (I do have no PG available for testing right now.) Yes that would work just as well. I assumed the example was a stripped down example of a large query that would benefit from the CTE. Btw: if you don't have Postgres available you can use http://sqlfiddle.com