I have a table that contains a list of metrics and their IDs in the format:
L6Metrics
| ID | Name |
--------------------------
| 734 | L6A_Velocity |
| 736 | L6B_Velocity |
| 738 | L6A_Target_Rate |
...
Each of these metrics has its own corresponding table containing timestamped historical data. If the metric has ID X
, then its historical data's table name is History_tX
. These history tables have the format:
History_t734
| DateTime | Value |
-----------------------------------------
| 2018-05-04 19:17:41.972 -05:00 | 33.9 |
| 2018-05-04 19:17:51.972 -05:00 | 36.3 |
| 2018-05-04 19:18:01.972 -05:00 | 35.1 |
...
Assuming that the timestamps across all of the history tables align, how can I use the L6Metrics
table to join all of the history tables on DateTime
to get the following:
| DateTime | History_t734 | History_t736 | ...
----------------------------------------------------------------
| 2018-05-04 19:17:41.972 -05:00 | 33.9 | 34.9 |
| 2018-05-04 19:17:51.972 -05:00 | 36.3 | 37.4 |
| 2018-05-04 19:18:01.972 -05:00 | 35.1 | 36.5 |
...
There are 75 rows in L6Metrics
(representing 75 history tables) so there would be 76 columns in my result. I have the ability to modify L6Metrics
if needed.