Re: [SQL] using a generated series in function

2011-12-17 Thread Bèrto ëd Sèra
Hi >From is not required if you use literals or function results (with literal > input parameters). If you came from Oracle you could simply think that the "FROM DUAL" bit can be omitted in Postgresql. There may be small differences, but that is the basic idea. Bèrto -- ==

Re: [SQL] using a generated series in function

2011-12-17 Thread David Johnston
>From 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 has >to come from somewhere and that location is the from/join part of the query. In your query foo.work_date is not a literal or function and s

Re: [SQL] using a generated series in function

2011-12-17 Thread Adrian Klaver
On Saturday, December 17, 2011 8:50:52 am John Fabiani wrote: > 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()

Re: [SQL] using a generated series in function

2011-12-17 Thread John Fabiani
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 ques

Re: [SQL] using a generated series in function

2011-12-16 Thread Adrian Klaver
On Friday, December 16, 2011 3:56:48 am John Fabiani wrote: > I have solved my problem. But this still does not explain the idea of > "from" From original query: ..(function_name(303, week_date::date)) as week_date where week_date.. Reason why that did not work: http://www.postgresql.org/doc

Re: [SQL] using a generated series in function

2011-12-16 Thread Misa Simic
what are u trying to do... But in second > > > query it seems there is missing "from" > > > > > > It is as > > > > > > SELECT week-date::date AS week-date WHERE week-date in (subquery which > > > have from) > > > > > > So

Re: [SQL] using a generated series in function

2011-12-16 Thread Misa Simic
ate AS week-date WHERE week-date in (subquery which > > have from) > > > > So week-date column in main query does not exist.. > > > > Sent from my Windows Phone From: John Fabiani > > Sent: 16 December 2011 05:16 > > To: pgsql-sql@postgresql.org &g

Re: [SQL] using a generated series in function

2011-12-16 Thread John Fabiani
me what are u trying to do... But in second > > query it seems there is missing "from" > > > > It is as > > > > SELECT week-date::date AS week-date WHERE week-date in (subquery which > > have from) > > > > So week-date column in main query

Re: [SQL] using a generated series in function

2011-12-16 Thread John Fabiani
ave from) > > So week-date column in main query does not exist.. > > Sent from my Windows Phone From: John Fabiani > Sent: 16 December 2011 05:16 > To: pgsql-sql@postgresql.org > Subject: [SQL] using a generated series in function > Hi, > > I am attempting (without su

Re: [SQL] using a generated series in function

2011-12-16 Thread Misa Simic
From: John Fabiani Sent: 16 December 2011 05:16 To: pgsql-sql@postgresql.org Subject: [SQL] using a generated series in function Hi, I am attempting (without success) use the generated series of dates that come from: select (cast(date_trunc('week', '2011-11-20'::date ) as da

Re: [SQL] using a generated series in function

2011-12-15 Thread David Johnston
On Dec 15, 2011, at 23:16, John Fabiani wrote: > Hi, > > I am attempting (without success) use the generated series of dates that come > from: > select (cast(date_trunc('week', '2011-11-20'::date ) as date) + (i+6)) as > week_date from generate_series(0,84,7) i > > in a function. > select fu

[SQL] using a generated series in function

2011-12-15 Thread John Fabiani
Hi, I am attempting (without success) use the generated series of dates that come from: select (cast(date_trunc('week', '2011-11-20'::date ) as date) + (i+6)) as week_date from generate_series(0,84,7) i in a function. select function_name(integer, date); -- function returns a numeric This do