Home > other >  What is a correct name for an operation that turns 3-column long table into a compact "2D"
What is a correct name for an operation that turns 3-column long table into a compact "2D"

Time:01-27

For example, from this table

row col val
0 A 32
0 B 31
0 C 35
1 A 30
1 B 29
1 C 29
2 A 15
2 B 14
2 D 18
3 A 34
3 B 39
3 C 34
3 D 35

it should produce this table:

A B C D
0 32 31 35
1 30 29 29
2 15 14 18
3 34 39 34 35

Is there some official, canonical (or at least popular specific unambiguous) term for such operation (or its reverse)?

I am trying to find (or implement & publish) a tool that transforms CSV this way, but am unsure what to search for (or how to name it).

CodePudding user response:

The term is pivot.

Some databases have native support for pivot, eg SQL Server's PIVOT (and even UNPIVOT) keywords.

For most databases you must craft a query that does the job.

  • Related