Is there a way to make a query more efficient by executing a sub-select only once?

In a query such as:

SELECT a, (select b from c where d = e limit 1), npoints( (select b from c where d = e limit 1) )
    FROM f
    WHERE isValid( (select b from c where d = e limit 1) );

I do the same sub-select 3 times in the query.  I tried the following:

SELECT a, (select b from c where d = e limit 1) AS g, npoints( g )
    FROM f
    WHERE isValid( g );

But this gave an error regarding "column 'g' does not exist".  How can I avoid making the same sub-select 3 times?

Mark
begin:vcard
fn:Mark Fenbers
n:Fenbers;Mark
org:DoC/NOAA/NWS/OHRFC
adr:;;1901 South SR 134;Wilmington;OH;45177-9708;USA
email;internet:[EMAIL PROTECTED]
title:Sr. HAS Meteorologist
tel;work:937-383-0430 x246
x-mozilla-html:TRUE
url:http://weather.gov/ohrfc
version:2.1
end:vcard

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

Reply via email to