sub-selects - Mailing list pgsql-sql

From Mark Fenbers
Subject sub-selects
Date
Msg-id 4288F867.8090600@noaa.gov
Whole thread Raw
Responses Re: sub-selects  (PFC <lists@boutiquenumerique.com>)
List pgsql-sql
Is there a way to make a query more efficient by executing a sub-select only once?<br /><br /> In a query such as:<br
/><br/><tt>SELECT a, (select b from c where d = e limit 1), npoints( (select b from c where d = e limit 1) )<br />    
FROMf<br />     WHERE isValid( (select b from c where d = e limit 1) );<br /></tt><br /> I do the same sub-select 3
timesin the query.  I tried the following:<br /><br /><tt>SELECT a, (select b from c where d = e limit 1)<b> AS g</b>,
npoints(<b>g</b> )<br />     FROM f<br />     WHERE isValid( <b>g</b> );<br /></tt><br /> But this gave an error
regarding"column 'g' does not exist".  How can I avoid making the same sub-select 3 times? <br /><br /> Mark<br /> 

pgsql-sql by date:

Previous
From: Ragnar Hafstað
Date:
Subject: Re: ORDER BY handling mixed integer and varchar values
Next
From: PFC
Date:
Subject: Re: sub-selects