Re: using a generated series in function - Mailing list pgsql-sql

From John Fabiani
Subject Re: using a generated series in function
Date
Msg-id 101859121.8q3HjkjhPI@linux-12
Whole thread Raw
In response to Re: using a generated series in function  (Adrian Klaver <adrian.klaver@gmail.com>)
Responses Re: using a generated series in function
Re: using a generated series in function
List pgsql-sql
As always I respect your insights - Adrian.  I do understand what I did wrong 
in my first attempt at getting my statement to work.  But it is either over my 
head or there is something missing.  Where is the "from" in
select now()?

I have been using similar SQL statements for years.  I never questioned why 
there was not a 'from' until this list noted that I was missing a 'From'.   I 
then went to the postgres site to read.  That's how I determined what I had 
done incorrectly.

I hope this is not one of those things like javascript where all white space 
is ignored unless it's not!  I hate that language!  It appears that everything 
needs a 'From' in SQL (reading the doc's) and the above statement is missing a 
'From'!

As always everyone - thanks for your help!

Johnf


On Friday, December 16, 2011 07:31:40 AM Adrian Klaver wrote:
> FROM Clause
> "select
> 
>     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 parentheses,
> and an alias must be provided for it. A VALUES command can also be used
> here. "
> 
> > 
> >
> > select foo.week_date, xchromasun._chromasun_getqtyordered(303,
> > foo.week_date) as week_qty from
> >
> >  (select ((date_trunc('week', '2011-11-20'::date )::date) + (i+6)) as
> >
> > week_date from generate_series(0,84,7)
> >
> >  i ) as foo
> > 
> >
> > The above works!


pgsql-sql by date:

Previous
From: Filip Rembiałkowski
Date:
Subject: Re: Natural sort order
Next
From: Adrian Klaver
Date:
Subject: Re: using a generated series in function