jakob / jakob/Postico

Automatic "PIVOT" function

Open
#499 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
486
Forks
8
PR merge metrics
No merged PRs in 30d

Description

Suppose you have data like this:

+-----------+-----------+-------+
| Day | Product | Sales |
+-----------+-----------+-------+
| Monday | Product A | 5 |
| Monday | Product B | 4 |
| Tuesday | Product A | 2 |
| Tuesday | Product B | 8 |
+-----------+-----------+-------+

But you want it like this:

+-----------+-----------+-----------+
| Day | Product A | Product B |
+-----------+-----------+-----------+
| Monday | 5 | 4 |
| Tuesday | 2 | 8 |
+-----------+-----------+-----------+

Then you need to "pivot", which means rearranging data from multiple rows into multiple columns.

PostgreSQL has a function `crosstab` in the `tablefunc` extension, but it is really cumbersome to use.
You can also use `CASE` or `FILTER` to create pivot tables like this, however that is also inconvenient. Also, all these methods require knowing the resulting columns beforehand.

It would be nice if we could add a feature to Postico that makes pivots easier.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the requested pivot behavior alongside PostgreSQL's tablefunc crosstab extension and the CASE or FILTER alternatives described in the issue. Define how Postico should create pivoted columns without requiring the resulting columns beforehand; done means the sample Day/Product/Sales data can be rearranged into the shown pivoted table.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.