纵表数据
MGMT_ENTITY_ID ATTR_NAME ATTR_VALUE
-------------- ---------------------- ---------------
1000 uuid spcos2
1020 hypervisor OpenStack
1030 vlanId 111
2000 uuid xian
2020 hypervisor OpenStack
2030 vlanId 111
301 cpunum 8
扫描二维码关注公众号,回复:
1225751 查看本文章
301 disk 1000
--------- 纵表转横表 -- 此语句支持查询了符合参数条件的 MGMT_ENTITY_ATTRIBUTE中的MGMT_ENTITY_ID select t1.MGMT_ENTITY_ID ,partyId from ( select met.MGMT_ENTITY_ID , sum(case met.ATTR_NAME when 'partyId' then met.ATTR_VALUE else null end) partyId, sum(case met.ATTR_NAME when 'isBand' then met.ATTR_VALUE else null end) isBand, sum(case met.ATTR_NAME when 'pdcId' then met.ATTR_VALUE else null end) pdcId from MGMT_ENTITY_ATTRIBUTE met group by met.MGMT_ENTITY_ID) t1 where t1.partyId='127612' and t1.isBand='123' and t1.pdcId='1000'