□やりたいこと
下記の'name'ごとに'value'列を分割して、再表示する際のSQLクエリ文についてご教授いただけますでしょうか。。
□mysqlバージョン
+------------+
| version() |
+------------+
| 5.1.73-log |
+------------+
□現状の出力結果
select from_unixtime(history.clock, '%Y-%m-%d %H:%i'), hosts.host, items.name, history.value from history
inner join items using( itemid )
inner join hosts using( hostid )
where hosts.host like '%hoge%'
and items.name like '%Temp%'
and from_unixtime(clock) between '2019-03-07 00:00' and '2020-03-08 00:00'
+------------------------------+-------------------+-----------+----------+
| from_unixtime(history.clock) | host | name | value |
+------------------------------+-------------------+-----------+----------+
| 2019-12-07 00:02 | hoge1 | Temp_CPU0 | -99.0000 |
| 2019-12-07 00:07 | hoge1 | Temp_CPU0 | -98.0000 |
| 2019-12-07 00:02 | hoge1 | Temp_CPU1 | -97.0000 |
| 2019-12-07 00:07 | hoge1 | Temp_CPU1 | -96.0000 |
| 2019-12-07 00:02 | hoge2 | Temp_CPU0 | -95.0000 |
| 2019-12-07 00:07 | hoge2 | Temp_CPU0 | -94.0000 |
| 2019-12-07 00:02 | hoge2 | Temp_CPU1 | -93.0000 |
| 2019-12-07 00:07 | hoge2 | Temp_CPU1 | -92.0000 |
□期待する出力結果
+------------------------------+-------------------+----------+----------+
| from_unixtime(history.clock) | host | Temp_CPU0| Temp_CPU1
+------------------------------+-------------------+----------+----------+
| 2019-12-07 00:02 | hoge1 | -99.0000 | -97.0000 |
| 2019-12-07 00:07 | hoge1 | -98.0000 | -96.0000 |
| 2019-12-07 00:02 | hoge2 | -95.0000 | -93.0000 |
| 2019-12-07 00:07 | hoge2 | -94.0000 | -92.0000 |