Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 478B616E34F8 for ; Sat, 17 Dec 2011 14:11:05 -0400 (AST) Received: from nm24.bullet.mail.ac4.yahoo.com ([98.139.52.221]) by makus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Rbyiq-0000dF-Qk for pgsql-sql@postgresql.org; Sat, 17 Dec 2011 18:11:05 +0000 Received: from [98.139.52.193] by nm24.bullet.mail.ac4.yahoo.com with NNFMP; 17 Dec 2011 18:10:48 -0000 Received: from [98.139.52.156] by tm6.bullet.mail.ac4.yahoo.com with NNFMP; 17 Dec 2011 18:10:48 -0000 Received: from [127.0.0.1] by omp1039.mail.ac4.yahoo.com with NNFMP; 17 Dec 2011 18:10:48 -0000 X-Yahoo-Newman-Id: 132537.3944.bm@omp1039.mail.ac4.yahoo.com Received: (qmail 63800 invoked from network); 17 Dec 2011 18:10:48 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=DKIM-Signature:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:References:Mime-Version:In-Reply-To:X-Apple-Yahoo-Original-Message-Folder:Content-Type:Content-Transfer-Encoding:Message-Id:Cc:X-Mailer:From:X-Apple-Yahoo-Replied-Msgid:Subject:Date:To; b=IXvqlw0puj17cyB0pKDhjhgnefsgR9hKFUpY2SmuzqhHXW6vnUCdPO/eFkjj35z0hDYlCkdPnTC/12BbThvd0RHk6fBy1jgpwzGSAQQ8unD6zAllsokwOGo1GbhenyyGc1fzvNfMDKtPlsEYrj3KjAxmXQHPxb3etJE17sk7s+k= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1324145448; bh=vjMalUvNIAjhJa1abQN1qBqUspjzAq/4/0cp4vhgSHM=; h=X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:References:Mime-Version:In-Reply-To:X-Apple-Yahoo-Original-Message-Folder:Content-Type:Content-Transfer-Encoding:Message-Id:Cc:X-Mailer:From:X-Apple-Yahoo-Replied-Msgid:Subject:Date:To; b=FlOIrFc8t0rz4wExuDIeSFxMoJi7ZGU3BaEi+TAnoPrEAUrHUwIFK5URuhAHckzWhzPf8iB3Lv5OQa6phwM48aTVPFPqUhEY1RiOicqu8haeP/HTn2k4DBndIVVZQM/dQCQ/svuPHQIoXk4qK9YaGmAof8tECc2tjsd5VnLCiDE= X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: u1QyW4cVM1l0xY63s67k9Al2zd_tHNtz.qitQpGfUq9n78o UpjZBD6Z.QsUDaBh6N3i5vm492xWwNEWm0WQv45LpLxyus5xoPHgzxhjbYAo hfQzPkmJXSG6r4CAXxK2hZvT_tl1NkMugFEvoeI9xbaPnTTP4ueBfzfE6iBM OlhU44gJvfjDZEUF_aLy5YNQLfmEJ4v8r6_XJlHSG4prryZcUu0XzP2MmJIK 87oLZY5oUJLTxXg3azqi1ODTNR6cTPYcqD3kQjDVWdOIZ1sBD2MoemqFkKKh m9VfgEhgV5tubeHvLpBNkV89Jr._aVCnbg6anBjwOJwD7d3IDfWuM2VpTzDt lYuAymBTRr400sFueHihQq7IEWZLdVJiKsy5uJqfvJYK9IEu9rcoX.Jfqr0l uoXeT2WbFhg-- X-Yahoo-SMTP: mpGJl6eswBD2IBufoVEg0Pa8gg-- Received: from [10.78.250.64] (polobo@198.228.198.195 with xymcookie) by smtp122-mob.biz.mail.ac4.yahoo.com with SMTP; 17 Dec 2011 10:10:47 -0800 PST References: <-6224470694062641569@unknownmsgid> <1424284.aaP0Qsvkam@linux-12> <201112160731.41028.adrian.klaver@gmail.com> <101859121.8q3HjkjhPI@linux-12> Mime-Version: 1.0 (iPad Mail 8J2) In-Reply-To: <101859121.8q3HjkjhPI@linux-12> X-Apple-Yahoo-Original-Message-Folder: Inbox Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Message-Id: <441A31E6-ECB7-4A3B-91E6-5D2F32830BFC@yahoo.com> Cc: "pgsql-sql@postgresql.org" X-Mailer: iPad Mail (8J2) From: David Johnston X-Apple-Yahoo-Replied-Msgid: 1_560236_AOCkiGIAAIpjTuzIjwBlr0/2IQ4 Subject: Re: using a generated series in function Date: Sat, 17 Dec 2011 13:10:40 -0500 To: John Fabiani X-Pg-Spam-Score: -4.1 (----) X-Archive-Number: 201112/70 X-Sequence-Number: 36131 =46rom is not required if you use literals or function results (with literal= input parameters). If you reference something that is not one of these it h= as to come from somewhere and that location is the from/join part of the que= ry. In your query foo.work_date is not a literal or function and so must be sour= ced from somewhere. 2011-11-20 is a literal being fed into a function and s= o does not require a =46rom clause in order to be evaluated. David J. On Dec 17, 2011, at 11:50, John Fabiani wrote: > As always I respect your insights - Adrian. I do understand what I did wr= ong=20 > in my first attempt at getting my statement to work. But it is either ove= r my=20 > head or there is something missing. Where is the "from" in > select now()? >=20 > I have been using similar SQL statements for years. I never questioned wh= y=20 > there was not a 'from' until this list noted that I was missing a 'From'. = I=20 > then went to the postgres site to read. That's how I determined what I ha= d=20 > done incorrectly. >=20 > I hope this is not one of those things like javascript where all white spa= ce=20 > is ignored unless it's not! I hate that language! It appears that everyt= hing=20 > needs a 'From' in SQL (reading the doc's) and the above statement is missi= ng a=20 > 'From'! >=20 > As always everyone - thanks for your help! >=20 > Johnf >=20 >=20 > On Friday, December 16, 2011 07:31:40 AM Adrian Klaver wrote: >> FROM Clause >> "select >>=20 >> A sub-SELECT can appear in the FROM clause. This acts as though its >> output were created as a temporary table for the duration of this single= >> SELECT command. Note that the sub-SELECT must be surrounded by parenthese= s, >> and an alias must be provided for it. A VALUES command can also be used >> here. " >>=20 >>>=20 >>>=20 >>> select foo.week_date, xchromasun._chromasun_getqtyordered(303, >>> foo.week_date) as week_qty from >>>=20 >>> (select ((date_trunc('week', '2011-11-20'::date )::date) + (i+6)) as >>>=20 >>> week_date from generate_series(0,84,7) >>>=20 >>> i ) as foo >>>=20 >>>=20 >>> The above works! >=20 > --=20 > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql