-
Notifications
You must be signed in to change notification settings - Fork 239
Open
Labels
Description
One thing SQL lacks is a idiom of converting:
| date | status | transaction |
|---|---|---|
| 2022-01-01 | live | 10 |
| 2022-01-01 | test | 20 |
| 2022-01-02 | live | 5 |
| 2022-01-02 | test | 30 |
| 2022-01-03 | live | 25 |
.. into ..
| date | live | test |
|---|---|---|
| 2022-01-01 | 10 | 20 |
| 2022-01-02 | 5 | 30 |
| 2022-01-03 | 25 | null |
.. and back.
There is many names for this, let's list them here:
- pandas
- MS Excel pivot tables
- dplyr/tidyverse
- polars
The problem has some unknowns which are treated differently by the functions above:
- what to do with unused columns?
- what to do with duplicated values?
- how to name the new columns?
Related comment #300 (comment)
Could be implemented as: https://stackoverflow.com/questions/69263964/how-to-pivot-in-postgresql
Would solve: https://old.reddit.com/r/SQL/comments/viumd0/bigquery_how_to_aggregate_data/
Currently I don't have capacity to tackle all these, so I'm just opening a tracking issue.
xavi-, librarianmage, MorozovG, futu2 and dufferzafar