You cannot. The DAL does not support the WITH statement. You have to
use db.executesql

On Oct 10, 1:55 am, Johann Spies <johann.sp...@gmail.com> wrote:
> On 8 October 2011 17:19, Massimo Di Pierro <massimo.dipie...@gmail.com>wrote:
>
> > Almost any query an be build using the dal.
>
> How would this type of postgresql-query be translated into DAL?
>
> 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;
>
> Regards
> Johann
> --
>  May grace and peace be yours in abundance through the full knowledge of God
> and of Jesus our Lord!  His divine power has given us everything we need for
> life and godliness through the full knowledge of the one who called us by
> his own glory and excellence.
>                                                     2 Pet. 1:2b,3a

Reply via email to