答案 0 :(得分:1)
您可以使用条件聚合:
select hk_district,
sum(complaint_no) filter (where month = '201801') as compaints_201801,
sum(complaint_no) filter (where month = '201802') as compaints_201802,
sum(complaint_no) filter (where month = '201803') as compaints_201803
from t
group by hk_district;