查存储过程语句:
语句案例:
CREATE OR REPLACE PROCEDURE ZHBB_rytj_heji
(dataYear IN VARCHAR,dataCode IN VARCHAR2,resultData out sys_refcursor)
is
BEGIN
-- 合计
open resultData for
SELECT
CASE when t.ryXzjbCount is null then 0 else t.ryXzjbCount end L01,
CASE when t1.ryZg is null then 0 else t1.ryZg end L02,
CASE when t1.ryXlBs is null then 0 else t1.ryXlBs end L03,
CASE when t1.ryXlSs is null then 0 else t1.ryXlSs end L04,
CASE when t1.ryXlBk is null then 0 else t1.ryXlBk end L05,
CASE when t1.ryXlDz is null then 0 else t1.ryXlDz end L06,
CASE when t1.ryXlZz is null then 0 else t1.ryXlZz end L07,
CASE when t1.ryXlGz is null then 0 else t1.ryXlGz end L08,
CASE when t1.ryAgeMt is null then 0 else t1.ryAgeMt end L09,
CASE when t1.ryAgeMf is null then 0 else t1.ryAgeMf end L10,
CASE when t1.ryAgeMff is null then 0 else t1.ryAgeMff end L11,
CASE when t1.ryAgeMs is null then 0 else t1.ryAgeMs end L12,
CASE when t1.ryAgeMso is null then 0 else t1.ryAgeMso end L13,
CASE when t1.ryGcZg is null then 0 else t1.ryGcZg end L14,
CASE when t1.ryGcGj is null then 0 else t1.ryGcGj end L15,
CASE when t1.ryGcZj is null then 0 else t1.ryGcZj end L16,
CASE when t1.ryGcCj is null then 0 else t1.ryGcCj end L17,
CASE when t1.ryJjZg is null then 0 else t1.ryJjZg end L18,
CASE when t1.ryJjGj is null then 0 else t1.ryJjGj end L19,
CASE when t1.ryJjZj is null then 0 else t1.ryJjZj end L20,
CASE when t1.ryJjCj is null then 0 else t1.ryJjCj end L21,
CASE when t1.ryChZg is null then 0 else t1.ryChZg end L22,
CASE when t1.ryChGj is null then 0 else t1.ryChGj end L23,
CASE when t1.ryChZj is null then 0 else t1.ryChZj end L24,
CASE when t1.ryChCj is null then 0 else t1.ryChCj end L25,
CASE when t1.ryQtZg is null then 0 else t1.ryQtZg end L26,
CASE when t1.ryQtGj is null then 0 else t1.ryQtGj end L27,
CASE when t1.ryQtZj is null then 0 else t1.ryQtZj end L28,
CASE when t1.ryQtCj is null then 0 else t1.ryQtCj end L29,
CASE when t1.ryJc is null then 0 else t1.ryJc end L30,
CASE when t1.ryNv is null then 0 else t1.ryNv end L31
FROM
(select sum(RY_XZJB_count) ryXzjbCount from ydgl.T_ZHGL_RYDY where 1= 1 and org_code in (select column_value as col from table(fn_split(dataCode,','))) and year = dataYear) t
full join
(SELECT
SUM(case WHEN RY_ID is not null then 1 else 0 end) ryZg,
SUM(case WHEN RY_XL_CODE = '01' then 1 else 0 end) ryXlBs,
SUM(case WHEN RY_XL_CODE = '02' then 1 else 0 end) ryXlSs,
SUM(case WHEN RY_XL_CODE = '03' then 1 else 0 end) ryXlBk,
SUM(case WHEN RY_XL_CODE = '04' then 1 else 0 end) ryXlDz,
SUM(case WHEN RY_XL_CODE = '05' then 1 else 0 end) ryXlZz,
SUM(case WHEN RY_XL_CODE != '00' and RY_XL_CODE != '01' and RY_XL_CODE != '02' and RY_XL_CODE != '03'
and RY_XL_CODE != '04' and RY_XL_CODE != '05' then 1 else 0 end) ryXlGz,
SUM(case WHEN (SYSDATE - RY_BIRTH) / 365 < 35 then 1 else 0 end) ryAgeMt,
SUM(case WHEN (SYSDATE - RY_BIRTH) / 365 >= 35 and (SYSDATE - RY_BIRTH) / 365 <= 45 then 1 else 0 end) ryAgeMf,
SUM(case WHEN (SYSDATE - RY_BIRTH) / 365 >= 46 and (SYSDATE - RY_BIRTH) / 365 <= 55 then 1 else 0 end) ryAgeMff,
SUM(case WHEN (SYSDATE - RY_BIRTH) / 365 >= 56 and (SYSDATE - RY_BIRTH) / 365 <= 60 then 1 else 0 end) ryAgeMs,
SUM(case WHEN (SYSDATE - RY_BIRTH) / 365 >= 61 then 1 else 0 end) ryAgeMso,
SUM(case WHEN RY_ZCXL_CODE = '01' and RY_ZC_CODE = '01' then 1 else 0 end) ryGcZg,
SUM(case WHEN RY_ZCXL_CODE = '01' and RY_ZC_CODE = '02' then 1 else 0 end) ryGcGj,
SUM(case WHEN RY_ZCXL_CODE = '01' and RY_ZC_CODE = '03' then 1 else 0 end) ryGcZj,
SUM(case WHEN RY_ZCXL_CODE = '01' and RY_ZC_CODE = '04' then 1 else 0 end) ryGcCj,
SUM(case WHEN RY_ZCXL_CODE = '02' and RY_ZC_CODE = '01' then 1 else 0 end) ryJjZg,
SUM(case WHEN RY_ZCXL_CODE = '02' and RY_ZC_CODE = '02' then 1 else 0 end) ryJjGj,
SUM(case WHEN RY_ZCXL_CODE = '02' and RY_ZC_CODE = '03' then 1 else 0 end) ryJjZj,
SUM(case WHEN RY_ZCXL_CODE = '02' and RY_ZC_CODE = '04' then 1 else 0 end) ryJjCj,
SUM(case WHEN RY_ZCXL_CODE = '03' and RY_ZC_CODE = '01' then 1 else 0 end) ryChZg,
SUM(case WHEN RY_ZCXL_CODE = '03' and RY_ZC_CODE = '02' then 1 else 0 end) ryChGj,
SUM(case WHEN RY_ZCXL_CODE = '03' and RY_ZC_CODE = '03' then 1 else 0 end) ryChZj,
SUM(case WHEN RY_ZCXL_CODE = '03' and RY_ZC_CODE = '04' then 1 else 0 end) ryChCj,
SUM(case WHEN RY_ZCXL_CODE = '04' and RY_ZC_CODE = '01' then 1 else 0 end) ryQtZg,
SUM(case WHEN RY_ZCXL_CODE = '04' and RY_ZC_CODE = '02' then 1 else 0 end) ryQtGj,
SUM(case WHEN RY_ZCXL_CODE = '04' and RY_ZC_CODE = '03' then 1 else 0 end) ryQtZj,
SUM(case WHEN RY_ZCXL_CODE = '04' and RY_ZC_CODE = '04' then 1 else 0 end) ryQtCj,
SUM(case WHEN RY_JCZ is not NULL then 1 else 0 end) ryJc,
SUM(case WHEN ry_sex = '女' then 1 else 0 end) ryNv
from ydgl.T_ZHGL_RYINFO where 1= 1 and org_code in (select column_value as col from table(fn_split(dataCode,','))) and year = dataYear ORDER BY ry_xzjb_code) t1
on 1 = 1;
end ZHBB_rytj_heji;