1)表名:macro_index_data
2)字段名:数据期(年月)(occur_period)、地区代码(area_code)、指标代码(index_code)、指标类型(增速、总量)(index_type)、指标值(index_value)、数据更新时间(update_time)。说明:罗湖区的区划代码为440305000000、GDP指标代码为gmjj_jjzl_01、指标类型的枚举值分别是增速(TB)、总量(JDZ)
3)请写出,2020年4个季度中GDP的增速都超过罗湖区同期的区有哪些
SQL如下:
--最后比较指标,若都大于即为所求的区
select t2.area_code
from (
--先求出罗湖区2020年四季度的GDP指标
select area_code,
sum(case when month('occur_period') between 1 and 3 then index_value else 0 end) `one`, --一季度GDP指标
sum(case when month('occur_period') between 4 and 6 then index_value else 0 end) `two`, --二季度GDP指标
sum(case when month('occur_period') between 7 and 9 then index_value else 0 end) `three`, --三季度GDP指标
sum(case when month('occur_period') between