There are more than a hundred sensors and thus that many columns in the matrix after the pivot. The final result set will be quite sparse since not all sensors have values for all the dates. How do I pivot the table without aggregation?
What is wrong with aggregation?
select timestamp, max(case when sensor_id = 'sensor1' then val end) as sensor1, max(case when sensor_id = 'sensor2' then val end) as sensor2, max(case when sensor_id = 'sensor3' then val end) as sensor3, . . . from t group by timestamp;
This seems like this simplest way to express the logic. And it probably performs a bit better than 100