Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Adding Support for CTEs #682

Open
frodo821 opened this issue Mar 26, 2023 · 0 comments
Open

Feature Request: Adding Support for CTEs #682

frodo821 opened this issue Mar 26, 2023 · 0 comments

Comments

@frodo821
Copy link

Hi, folks. I want support for CTEs (common table expressions) as a new feature of PonyORM.

Motivation

Some queries require using CTEs. For instance, a query using window functions as a filter condition needs CTE like this:

WITH q(`id`, `sum_price`) AS (
  SELECT `id`, sum(`price`) OVER (order by `last_updated` desc) AS `count` FROM `items`
)
SELECT `id` FROM `q`
WHERE `sum_price` < 20;

As a limitation over window functions of standard SQL, it never allows using window functions in WHERE/HAVING clause. Because of this reason, CTE is inevitable for this query.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant