Converting PostgreSQL Rows To Columns With SPL Pivot Function
Pivot data from rows to columns using SPL: Query Postgresql, use pivot function with grouping column & Key column, convert values to new column names & values.
The query results of the Postgresql database return 6 columns, with the first column being the grouping column, the second column being the Value column within the group, and columns 3-6 being the Key columns within the group. Each record only has one Key column with a value, while the other Key columns are null. The position of the Key with a value for each record is uncertain. Now we need to keep the grouping column unchanged, convert the details within the group from rows to columns, convert the values of non-null Key columns to new column names, and convert the values of Value column to n...