pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
sub-selects
2+ messages / 2 participants
[nested] [flat]

* sub-selects
@ 2005-05-16 19:45  Mark Fenbers <Mark.Fenbers@noaa.gov>
  0 siblings, 1 reply; 2+ messages in thread

From: Mark Fenbers @ 2005-05-16 19:45 UTC (permalink / raw)
  To: pgsql-sql

This is a multi-part message in MIME format.
--------------090105060904060804060108
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#333399">
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>
&nbsp;&nbsp;&nbsp; FROM f<br>
&nbsp;&nbsp;&nbsp; WHERE isValid( (select b from c where d = e limit 1) );<br>
</tt><br>
I do the same sub-select 3 times in the query.&nbsp; 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>
&nbsp;&nbsp;&nbsp; FROM f<br>
&nbsp;&nbsp;&nbsp; WHERE isValid( <b>g</b> );<br>
</tt><br>
But this gave an error regarding "column 'g' does not exist".&nbsp; How can
I avoid making the same sub-select 3 times? <br>
<br>
Mark<br>
</body>
</html>

--------------090105060904060804060108
Content-Type: text/x-vcard; charset=utf-8;
 name="Mark.Fenbers.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="Mark.Fenbers.vcf"

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:Mark.Fenbers@noaa.gov
title:Sr. HAS Meteorologist
tel;work:937-383-0430 x246
x-mozilla-html:TRUE
url:http://weather.gov/ohrfc
version:2.1
end:vcard


--------------090105060904060804060108--



Attachments:

Mark.Fenbers.vcf (text/x-vcard, 281B) download 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:Mark.Fenbers@noaa.gov title:Sr. HAS Meteorologist tel;work:937-383-0430 x246 x-mozilla-html:TRUE url:http://weather.gov/ohrfc version:2.1 end:vcard
^ permalink raw reply [nested|flat] 2+ messages in thread

* Re: sub-selects
@ 2005-05-16 20:36  PFC <lists@boutiquenumerique.com>
  parent: Mark Fenbers <Mark.Fenbers@noaa.gov>
  0 siblings, 0 replies; 2+ messages in thread

From: PFC @ 2005-05-16 20:36 UTC (permalink / raw)
  To: Mark Fenbers <Mark.Fenbers@noaa.gov>; pgsql-sql


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

?



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-05-16 20:36 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-05-16 19:45 sub-selects Mark Fenbers <Mark.Fenbers@noaa.gov>
2005-05-16 20:36 ` PFC <lists@boutiquenumerique.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox