-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
ask for pivot feature #50477
Comments
duckdb design |
Snowflake has this as well https://docs.snowflake.com/en/sql-reference/constructs/pivot |
Bumping as this is super useful and painful without |
+1 +1 +1 |
Aggregate combinators seems to solve pivot https://clickhouse.com/blog/aggregate-functions-combinators-in-clickhouse-for-arrays-maps-and-states SELECT
countIf((status = 'confirmed') AND (confirm_time > (create_time + toIntervalMinute(1)))) AS num_confirmed_checked,
sumIf(total_amount, (status = 'confirmed') AND (confirm_time > (create_time + toIntervalMinute(1)))) AS confirmed_checked_amount,
countIf(status = 'declined') AS num_declined,
sumIf(total_amount, status = 'declined') AS dec_amount,
avgIf(total_amount, status = 'declined') AS dec_average
FROM payments
┌─num_confirmed_checked─┬─confirmed_checked_amount─┬─num_declined─┬────────dec_amount─┬───────dec_average─┐
│ 39 │ 11195.98991394043 │ 50 │ 10780.18000793457 │ 215.6036001586914 │
└───────────────────────┴──────────────────────────┴──────────────┴───────────────────┴───────────────────┘ |
@anjmao doesn't this require manually enumerating values? What if I had 50 distinct values |
I've tried solution with argMaxIf (get last values by created_at for specific column value) with 200+ values/columns. Got an issue with memory usage, every new value/column requires more and more memory. |
please add the pivot/unpivot statement in clickhouse.
Discussed in #50473
Originally posted by l1t1 June 2, 2023
oracle, duckdb
https://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_10002.htm#SQLRF01702
https://duckdb.org/docs/sql/statements/pivot
The text was updated successfully, but these errors were encountered: