Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id EA2B82BF80 for ; Fri, 16 Dec 2011 05:31:11 -0400 (AST) Received: from mail-iy0-f174.google.com ([209.85.210.174]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RbU8C-0004fF-9o for pgsql-sql@postgresql.org; Fri, 16 Dec 2011 09:31:12 +0000 Received: by iaeh11 with SMTP id h11so4110099iae.19 for ; Fri, 16 Dec 2011 01:30:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; bh=VkDXYWpJgutOHZc7m9y3DSarVO3HYi/R3oLVdZZC2cg=; b=oz6AGcPlQDntjSeqHJBWqYUsIvIJkuGJb+cKLTa6w8i/AoHZKoSYkZ84qWtH7g8ZCr INQ2WDQOQS2UVpPhJiCsNLRC2kGsaQrOEBMVDyweG8IXAL1SzazKUbjc2Y3miSAI8kSL OAnfYhJUOAflLiOSrbtBPen/YB1LH47gozZ70= Received: by 10.50.190.202 with SMTP id gs10mr7714260igc.63.1324027854406; Fri, 16 Dec 2011 01:30:54 -0800 (PST) MIME-Version: 1.0 From: Misa Simic Date: Fri, 16 Dec 2011 01:30:53 -0800 Message-ID: <-6224470694062641569@unknownmsgid> Subject: Re: using a generated series in function To: John Fabiani , "pgsql-sql@postgresql.org" Content-Type: text/plain; charset=UTF-8 X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201112/57 X-Sequence-Number: 36118 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 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 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 does NOT work: select (function_name(303, week_date::date)) as week_date where week_date in (select (cast(date_trunc('week', '2011-11-20'::date ) as date) + (i+6)) as week_date from generate_series(0,84,7) i ) The error is: ERROR: column "week_date" does not exist LINE 1: select (xchromasun._chromasun_getqtyordered(303, week_date::... I hope I can do this? What am I doing wrong? Johnf -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql