Skip to content

Pivot and melt #644

Description

@aljazerzen

One thing SQL lacks is a idiom of converting:

datestatustransaction
2022-01-01live10
2022-01-01test20
2022-01-02live5
2022-01-02test30
2022-01-03live25

.. into ..

datelivetest
2022-01-011020
2022-01-02530
2022-01-0325null

.. and back.

There is many names for this, let's list them here:

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions