通过行换列处理之后:
SELECT s.AREA_NAME,
max(CASE s.TYPE WHEN ‘CPU‘ THEN s.PRICE ELSE 0 end)CPU,
max(CASE s.TYPE WHEN ‘Bandwidth‘ THEN s.PRICE ELSE 0 end)Bandwidth,
max(CASE s.TYPE WHEN ‘Storage‘ THEN s.PRICE ELSE 0 end)Storage,
max(CASE s.TYPE WHEN ‘Memory‘ THEN s.PRICE ELSE 0 end)Memory
FROM (SELECT
a.AREA_NAME,
t.TYPE,
cast(t.PRICE as FLOAT) as PRICE
FROM
CSP_BASE_PRICE_INFO t,
SYS_AREA a
WHERE
a.AREA_ID = t.AREA_ID
AND t.TYPE IN (
‘CPU‘,
‘Bandwidth‘,
‘Storage‘,
‘Memory‘
)
AND T.PRICE_TYPE = ‘ToPackage‘) s
GROUP BY s.AREA_NAME
结果就变成下面这样了