Skip to content
Advertisement

Displaying one row with one timestamp and a corresponding x-integer array as x rows with x timestamps and one corresponding integer

Apologies for the poorly worded question, I don’t know how to succinctly describe my problem. I am working with data from a sensor that scans a room every 10 minutes to see how many people are in it. The data looks something like this

Is there any way I can have it look like this?

I’m not sure what would happen to the reading_id but I do not need it regardless.

Advertisement

Answer

You can use unnest with ordinality to get the index of each array element and use that to add the 10 minute intervals.

Online example: https://rextester.com/TEB87353

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement