Re: [SQL] using a generated series in function

2011-12-16 Thread Misa Simic
It is not totally clear to 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 does not exist.. Sent from my Windows Phone From: John Fabia

Re: [SQL] using a generated series in function

2011-12-16 Thread John Fabiani
Actually what would the "from" be - this could be a newbie issue here? Neither statement requires a "from" because neither of the statements uses a table - I think! I'll try to add one but the first part is a function like a any other function. What is the "from" when you do: "select now()"

Re: [SQL] using a generated series in function

2011-12-16 Thread John Fabiani
I have solved my problem. But this still does not explain the idea of "from" 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

Re: [SQL] using a generated series in function

2011-12-16 Thread Misa Simic
Hi John, Well, maybe the best would be to say on english what you want to achieve... >From SQL code in your mail - it is not clear ( at least to me...) but: SELECT now() - it will just execute function ant there is not possible to say WHERE in that... and like you said: *select function_name(i

Re: [SQL] using a generated series in function

2011-12-16 Thread Misa Simic
That is good - that you solved it... Well - in from it does not need to be just from table... it needs to be some set of rows... is it Table or function (SELECT i FROM generate_series(0, 84, 7) i - is actually from function...) or from View... SELECT * FROM (SELECT * FROM Table1) as InlineView

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

[SQL] Column "..." does not exist (view + union)

2011-12-16 Thread Stefan Weiss
Assuming the following simple setup with two data tables, one mapping table, and one view - -- CREATE TABLE dossier ( id SERIAL NOT NULL PRIMARY KEY ); CREATE TABLE contact ( id SERIAL NOT NULL PRIMARY K