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

bug: pivot query can not support subquery #16556

Open
1 of 2 tasks
cdmikechen opened this issue Oct 1, 2024 · 0 comments
Open
1 of 2 tasks

bug: pivot query can not support subquery #16556

cdmikechen opened this issue Oct 1, 2024 · 0 comments
Labels
C-bug Category: something isn't working

Comments

@cdmikechen
Copy link

Search before asking

  • I had searched in the issues and found no similar issues.

Version

v1.2.615

What's Wrong?

pivot does not support subquery

How to Reproduce?

referenced document: https://docs.databend.com/sql/sql-commands/query-syntax/query-pivot

error sql:

SELECT * 
FROM (select * from monthly_sales)
PIVOT(SUM(amount) FOR MONTH IN (select distinct month from monthly_sales))
ORDER BY EMPID;

If I use a view, databend can support subquey in from:

create view v_monthly_sales as select * from monthly_sales;
 
SELECT * 
FROM v_monthly_sales
PIVOT(SUM(amount) FOR MONTH IN ('JAN', 'FEB', 'MAR', 'APR'))
ORDER BY EMPID;

Assuming all months are in the results and need to be used, how can I do the query correctly without writing a for?

Are you willing to submit PR?

  • Yes I am willing to submit a PR!
@cdmikechen cdmikechen added the C-bug Category: something isn't working label Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant