--22、超高电价占比 ---地市(可由网格数据汇聚) select smonth, city_name, count(*) as total_num, sum(case when y.eprice>0.8 then 1 else 0 end) as high_price_num, sum(case when y.eprice>0.8 then 1 else 0 end)/count(*)::numeric as high_price_rate from (select *,(case when accrued_power=0 then 0 else accrued_cost/accrued_power end) as eprice from sqmdb_cost.ytmx_new) y group by smonth,city_name ---网格 select smonth, city_name, area_name, count(*) as total_num, sum(case when y.eprice>0.8 then 1 else 0 end) as high_price_num, sum(case when y.eprice>0.8 then 1 else 0 end)/count(*)::numeric as high_price_rate from (select *,(case when accrued_power=0 then 0 else accrued_cost/accrued_power end) as eprice from sqmdb_cost.ytmx_new) y group by smonth,city_name,area_name