rewriting query to move filter conditionout of a subselect

From: "Rhys Stewart" <rhys(dot)stewart(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: rewriting query to move filter conditionout of a subselect
Date: 2006-10-11 14:06:12
Message-ID: 189966030610110706w7bf81794mcb1354cd41a3aa68@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all I have the following query that sources two tables:

select pi2.* from allpoints2 a1
inner join prem_info pi2 on pi2.prem = a1.prem AND the_geom is null
AND pi2.multiplier > 1
where route in
(select route from prem_info pi
inner join allpoints2 a on a.prem = pi.prem
where feederid = '241/6-210'
group by route)

is it possible to rewrite the query so that i can filter for feederid
outside of a subselect, (so that i could call it from a view maybe) or
should i do a set returning function ?

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2006-10-11 14:12:42 Re: query log corrupted-looking entries
Previous Message Simon Riggs 2006-10-11 14:03:49 Re: How does PG access wal files?