Search Postgresql Archives

Re: sql or pgsql question, accessing a created value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



select my_function( timeofmeasurement, longitude ) as solarnoon,
        extract(epoch from ( timeofmeasurement - solarnoon ) as solardiff
        ( case when solardiff < 3600 then 'Y' else 'N' end ) as
within_solar_hour from
    my_table;

But I get an error along the lines of
ERROR:  column "solarnoon" does not exist LINE 8:  extract(epoch from
(timeofmeasurement - solarnoon) ) as sola...

It's probably a compile-time run-time sort of chicken and egg thing. ;)

>>>>>>>>>>>>>>>>>>>>>>>>>

It is.  You need to use sub-selects.

SELECT solarnoon, solardiff, CASE... AS within_solar_hour
FROM
SELECT solarnoon, func() AS solardiff
FROM (
SELECT func() AS solarnoon
) AS sn -- close solarnoon from
) AS sd -- close solardiff from


David J.


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux