<div dir="ltr"><div><div>Hi<br></div>I'm slowly learning postgis ... <br></div>I have these 3 SELECTS that works well when run independently, but I'm now trying to use them together in a WITH query, and I cannot make it run. What I'm doing wrong?<br><br>WITH <br>positiu AS (<br>    SELECT rid, ST_Reclass(ST_Band(rast, 1), 1, '[1-10000]:1', '16BSI', 0) <br>    FROM rastertmp.prova<br>),<br>isok AS (SELECT t1.rid, ST_Union(ST_Intersection(t1.rast, 1, t2.rast, 1, 'BAND1'))<br>    FROM rastertmp.prova AS t1, positiu AS t2<br>    WHERE ST_Intersects(t1.rast, t2.rast)<br>        GROUP BY t1.rid<br>),<br>clips AS (<br>    SELECT p.ecoregion_cod, ST_Union(ST_Clip(r.rast,1, p.geom, true)) AS rast<br>    FROM gis_wd.wd_ecoregiones AS p, isok AS r<br>    WHERE ST_Intersects(r.rast, p.geom)<br>    GROUP BY ecoregion_cod <br>)<br>SELECT ecoregion_cod, (ST_SummaryStats(rast, 1)).* FROM clips <br><br>-- ERROR: column t2.rast does not exist<br><br><br><div>In fact, I'm assuming that running these SELECTS in a single WITH query is more efficient (faster?) than running each one separately, generating intermediate tables (less disk access?). But perhaps I'm wrong, any idea?<br></div><div><div><div><br>Thanks<br></div><div><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr">Juli<div><span style="color:rgb(51,51,153)">--</span><br><font color="#333399"><b>CIDE, CSIC</b>  |  <a href="http://www.uv.es/jgpausas" target="_blank">www.uv.es/jgpausas</a>  | <br><br></font></div></div></div></div></div></div>
</div></div></div></div>