select A.AREA,A.COMCODE,A.MONTHSCALEPREMIUM,A.MONTHSCALEPREMIUMYOY,A.BILLSCALEPREMIUM_Y,
A.BILLSCALEPREMIUM_YYOY,A.MONTHSCALEPREMIUM_Y,A.MONTHSCALEPREMIUM_YYOY,A.PAYMENTSPREMIUM_Y,
A.PAYMENTSPREMIUM_YYOY,B.MONTHSCALEPREMIUMYOY,B.BILLSCALEPREMIUM_YYOY,B.MONTHSCALEPREMIUM_YYOY,
b.PAYMENTSPREMIUM_YYOY
from (
select DATATIME,AREA,COMCODE,MONTHSCALEPREMIUM,MONTHSCALEPREMIUMYOY,BILLSCALEPREMIUM_Y,BILLSCALEPREMIUM_YYOY
,MONTHSCALEPREMIUM_Y,MONTHSCALEPREMIUM_YYOY,PAYMENTSPREMIUM_Y,PAYMENTSPREMIUM_YYOY
from LIBAPDATAGATHER where AREA<>'地区' and AREA<>'合计'
and to_char(DATATIME,'YYYY"年"mm"月"') in (^P_PARAM.tjxtcs.LIBAPDATAGATHER_时间^)
and COMCODE in (^P_PARAM.tjxtcs.LIBAPDATAGATHER_机构名称^)
) A left join
(
select DATATIME,AREA,COMCODE,MONTHSCALEPREMIUMYOY,BILLSCALEPREMIUM_YYOY,MONTHSCALEPREMIUM_YYOY
,PAYMENTSPREMIUM_YYOY
from LIBAPDATAGATHER where AREA<>'地区' and AREA<>'合计'
) B on
B.DATATIME =add_months(A.DATATIME,-12)
and A.AREA = B.AREA and A.COMCODE =B.COMCODE
我通过SQL把去年同期值一并查了出来,有需要的伙伴参考一下 |