I'm trying to use Postgresql 9.2 <a href="http://www.postgresql.org/docs/9.2/static/queries-with.html">Commom Table Expressions</a> in queries that will be loaded in QGIS 1.8 (windows vista) using DBManager.<div><br></div>
<div>Here's a very simple (and useless) example:<div><br></div><div><p style="margin:0px"><font face="courier new, monospace">WITH query_1 as (</font></p>
<p style="margin:0px"><font face="courier new, monospace">    SELECT *</font></p>
<p style="margin:0px"><font face="courier new, monospace">    FROM "PDM".pdm_compare)</font></p>
<p style="margin:0px"><font face="courier new, monospace">SELECT *</font></p>
<p style="margin:0px"><font face="courier new, monospace">FROM query_1</font></p><div><div><br></div><div>In DBManager SQLWindow, I'm able to execute and see the table results, but when I try to load it QGIS Canvas (selecting the Id and geometry columns), I got the following error in the postgis warning tab:</div>
</div></div><div><br></div><div><div>Erroneous query: SELECT * FROM "(WITH query_1 as (</div><div><span class="Apple-tab-span" style="white-space:pre">    </span>SELECT *</div><div><span class="Apple-tab-span" style="white-space:pre">     </span>FROM ""PDM"".pdm_compare)</div>
<div>SELECT *</div><div>FROM query_1</div><div>)" LIMIT 1 returned 7 [ERROR:  relation "(WITH query_1 as (</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>SELECT *</div><div><span class="Apple-tab-span" style="white-space:pre">     </span>FROM "PDM".pdm_compare)</div>
<div>SELECT *</div><div>" does not exist</div><div>LINE 1: SELECT * FROM "(WITH query_1 as (</div><div>                      ^</div><div>]</div></div><div><br></div><div>I tried using qgis 1.9 and I was able to load the query. Is this a known problem in 1.8? Is there a workaround so I can use WITH statements in QGIS 1.8.</div>
</div><div><br></div><div>Thanks,</div><div><br></div><div>Alexandre Neto </div>