GBase 8a provides pivot for turning rows into columns, also called a data pivot. This post walks through the syntax and a progressive set of examples for the China-domestically developed GBase 8a MPP database from GBASE. Student names and the subject labels in the sample tables are translated into English below; all column names, numeric values and row orders stay exactly as in the original output.
Syntax
pivot ( < aggregate_function > ( < column_to_aggregate > ) [ as alias ] [ , < aggregate_function > ( < column_to_aggregate > ) [ as alias ] . . . ] for < column1 [ , column2 . . . ] > in ( constant1 [ as alias1 ] [ , constant2 [ as alias2 ] . . . ] ) )
Enter fullscreen mode
Exit fullscreen mode
Notes
The aggregate part supplies the values of the new columns, and several aggregates are allowed.
for names the column to rotate. Eligible column values are listed in in . With a single column the parentheses can be omitted ( for column_name in ...…