PostgreSQL Pivot Table – Pivoting Multiple Column Values

pivotpostgresql

Is it possible to crosstab a table in PostgreSQL without having to define an "as" clause given by a tuple (column type)?

Example: The created table "t" would have only 3 columns '1', '2' and '3'.

CREATE TABLE IF NOT EXISTS t (
   id_ INTEGER  NOT NULL,
   value1 INT NOT NULL
)

INSERT INTO t (id_, value1) VALUES
(1, 10),
(1, 20),
(2, 10),
(2, 20),
(2, 20),
(3, 30),
(3, 20)

Best Answer

"without having to define an "as" clause given by a tuple" - no, not possible @a_host_with_no_name