https://stackoverflow.com/questions/1241178/mysql-rows-to-columns
select
d2.host_id,
ifnull(sum(d2.A),0) as A,
ifnull(sum(d2.B),0) as B,
ifnull(sum(d2.C),0) as C
from
(select
demo2.*,
case when item_name='A' then item_value end as A,
case when item_name='B' then item_value end as B,
case when item_name='C' then item_value end AS C
from demo2) AS d2
GROUP by d2.host_id;
'Develop' 카테고리의 다른 글
Protobuf reserved (0) | 2022.06.25 |
---|---|
젠킨스 파이프라인에서 다른 job 실행 (0) | 2022.04.01 |
DocumentDB failover 장애 시간 (0) | 2021.09.28 |
nodeJs Buffer (0) | 2021.04.09 |
aws elasticcache MOVED 문제 (0) | 2021.02.02 |