SELECT * FROM pivot ( ON pivot_input PARTITION BY sn, city, week ORDER BY week PartitionColumns ('sn', 'city', 'week') PivotKeys ('temp', 'pressure') PivotColumn ('attribute') TargetColumns ('value') ) ORDER BY 1,2,3;
The ORDER BY clause is required. If omitted, the output table column content is nondeterministic.