【本期sql】select ${if(RG_REPORT_TYPE=="month", " a.tongjirq as 实际日期, to_char(to_date(tongjirq,'yyyymmdd'),'dd') as 日期, ", " a.tongjiyf as 实际日期, a.tongjiyf as 日期, " )} sum(a.RENYUANSHU) as 人员数_本期, 0 as 人员数_同期 ${if(RG_REPORT_TYPE=="month", " from REPORT_V_RENLIZY a where a.tongjirq between to_char(to_date('"+P_YEARMONTH+"-01','yyyy-mm-dd'),'yyyymmdd') and to_char(last_day(to_date('"+P_YEARMONTH+"','yyyy-mm')),'yyyymmdd')", "")}${if(RG_REPORT_TYPE=="quarter", " from REPORT_V_RENLIZY_m a where a.tongjiyf BETWEEN '"+P_YEAR+""+P_QUARTER+"' AND TO_CHAR(add_months(to_date('"+P_YEAR+"-"+P_QUARTER+"','yyyy-mm'),3)-1,'YYYYMM')", "")}${if(RG_REPORT_TYPE=="year", " from REPORT_V_RENLIZY_m a where a.tongjiyf like '"+P_YEAR+"%'", "")}${if(len(P_YILIAOJG)==0,"","AND a.YILIAOJGDM = '"+P_YILIAOJG+"'")}${if(len(P_KESHIDM)==0, "", " and a.keshidm in ('" + P_KESHIDM + "')")}${if(RG_REPORT_TYPE=="month", " group by a.tongjirq order by a.tongjirq "," group by a.tongjiyf order by a.tongjiyf ")}【同期sql】select ${if(RG_REPORT_TYPE=="month", " a.tongjirq as 实际日期, to_char(to_date(tongjirq,'yyyymmdd'),'dd') as 日期, ", " a.tongjiyf as 实际日期, a.tongjiyf as 日期, " )} 0 as 人员数_本期, sum(a.RENYUANSHU) as 人员数_同期 ${if(RG_REPORT_TYPE=="month", " from REPORT_V_RENLIZY a where a.tongjirq between to_char(add_months(to_date('"+P_YEARMONTH+"-01','yyyy-mm-dd'),-12),'yyyymmdd') and to_char(add_months(last_day(to_date('"+P_YEARMONTH+"','yyyy-mm')),-12),'yyyymmdd')", "")}${if(RG_REPORT_TYPE=="quarter", " from REPORT_V_RENLIZY_m a where a.tongjiyf BETWEEN to_char(add_months(to_date( '"+P_YEAR+""+P_QUARTER+"','yyyymm'),-12) ,'yyyymm')AND TO_CHAR(add_months(to_date('"+P_YEAR+"-"+P_QUARTER+"','yyyy-mm'),-12+3)-1,'YYYYMM')", "")}${if(RG_REPORT_TYPE=="year", " from REPORT_V_RENLIZY_m a where a.tongjiyf like '"+(TOINTEGER(P_YEAR)-1)+"%'", "")}${if(RG_REPORT_TYPE=="month", " group by a.tongjirq order by a.tongjirq "," group by a.tongjiyf order by a.tongjiyf ")}