Bom dia,

        Estou com problema de utilização da cláusula WITH com SELECT. Segundo 
manual poderia utiliza-lo da seguinte forma:


7.8. WITH Queries

WITH provides a way to write subqueries for use in a larger SELECT query. The 
subqueries can be

thought of as defining temporary tables that exist just for this query. One use 
of this feature is to break

down complicated queries into simpler parts. An example is:

WITH regional_sales AS (

SELECT region, SUM(amount) AS total_sales

FROM orders

GROUP BY region

), top_regions AS (

SELECT region

FROM regional_sales

WHERE total_sales > (SELECT SUM(total_sales)/10 FROM regional_sales)

)

SELECT region,

product,

SUM(quantity) AS product_units,

SUM(amount) AS product_sales

FROM orders

WHERE region IN (SELECT region FROM top_regions)

GROUP BY region, product;

    Só que quando tento utilizar no pgAdmin um exemplo parecido, me é 
apresentado o seguinte erro:

ERROR: syntax error at or near "with"
SQL state: 42601

    Alguém poderia ajudar?




_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a