I have a table where I insert values, related to an id, that change over time.
Example:
| Id | Timestamp | Value | | 1 | 2018-09-12 02:29:31.154 | 7.139 | | 1 | 2018-09-12 02:40:46.724 | 7.254 | | 2 | 2018-09-06 02:40:46.724 | 132.451 | | 1 | 2018-09-12 02:42:19.841 | 7.645 | | 3 | 2018-09-12 03:01:45.811 | 45.276 | | 1 | 2018-09-12 03:12:59.121 | 7.421 | | 2 | 2018-09-12 03:12:59.121 | 130.789 | | 1 | 2018-09-12 03:15:33.467 | 7.121 | | 2 | 2018-09-12 03:15:33.467 | 136.198 | | 3 | 2018-09-12 03:15:33.467 | 46.971 | | 2 | 2018-09-12 03:27:13.642 | 131.879 | | 3 | 2018-09-12 03:27:13.642 | 44.645 | | 1 | 2018-09-12 03:30:27.564 | 7.691 | | ... | ... | ... |
My goal is to make a single query to take values between a range of dates for Id
1, 2 and 3 and marge them together.
The result will be something like this:
{ Timestamp: "2018-09-12 02:29:31.154", id1: 7.123, id2: null, id3: null }
{ Timestamp: "2018-09-12 02:40:46.724", id1: 7.254, id2: 132.451, id3: null }
{ Timestamp: "2018-09-12 02:42:19.841", id1: 7.645, id2: null, id3: null }
{ Timestamp: "2018-09-12 03:01:45.811", id1: null, id2: null, id3: 45.276 }
{ Timestamp: "2018-09-12 03:12:59.121", id1: 7.421, id2: 130.789, id3: null }
{ Timestamp: "2018-09-12 03:15:33.467", id1: 7.121, id2: 136.198, id3: 46.971 }
{ Timestamp: "2018-09-12 03:27:13.642", id1: null, id2: 131.879, id3: 44.645 }
{ Timestamp: "2018-09-12 03:30:27.564", id1: 7.691, id2: null, id3: null }
Is it possible in a single query?