一:交叉表 格子内是平均值,格子的下方是 计算和
二:sql语句:
SELECT 'Requesting clinical services' AS TYPE,
F.FRM_NAME,
F.FRM_NUM,
F.FRM_NUM AS FORNUM,
NULL SITE_COD,
AVG(FLOOR(IR.RPT_RCV_DATETIME - R.RQST_DATETIME)) IRDAY,
C.SVC_NAME
FROM IVG_RQST R,
IVG_FRM F,
CLC_ENCNTR E,
COD_SVC C,
IVG_RPT IR
WHERE R.IVG_FRM_ID = F.IVG_FRM_ID
AND R.CLC_ENCNTR_ID = E.CLC_ENCNTR_ID
AND E.COD_SVC_ID = C.COD_SVC_ID
AND R.IVG_RQST_ID = IR.IVG_RQST_ID
and C.IS_ACTIVE=1
-- AND ((SELECT CASE
-- WHEN '{?Frequency}' = 'Yearly' THEN
-- (SELECT 1
-- FROM DUAL
-- WHERE TO_CHAR(IR.RPT_RCV_DATETIME, 'YYYY') = '{?Year}')
-- WHEN '{?Frequency}' = 'Monthly' THEN
-- (SELECT 1
-- FROM DUAL
-- WHERE TO_CHAR(IR.RPT_RCV_DATETIME, 'YYYY') = substr('{?Month}',1,4)
-- AND TO_CHAR(IR.RPT_RCV_DATETIME, 'MM') = substr('{?Month}',6,2)
--)
--
--WHEN '{?Frequency}' = 'Daily' THEN
-- (SELECT 1
-- FROM DUAL
-- WHERE TO_CHAR(IR.RPT_RCV_DATETIME, 'yyyy-mm-dd') = TO_CHAR({?Date}, 'yyyy-mm-dd'))
--
--
--
--WHEN '{?Frequency}' = 'User Specified' THEN
-- (SELECT 1
-- FROM DUAL
-- WHERE TRUNC(IR.RPT_RCV_DATETIME) BETWEEN
-- {?Start date} AND {?End date})
--
--
--
-- END CASE
-- FROM DUAL) = 1)
GROUP BY F.FRM_NAME, F.FRM_NUM, C.SVC_NAME
UNION ALL
SELECT 'Requesting clinics/units' AS TYPE,
F.FRM_NAME,
F.FRM_NUM,
F.FRM_NUM AS FORNUM,
C.SITE_COD,
AVG(FLOOR(IR.RPT_RCV_DATETIME - R.RQST_DATETIME)) AS IRDAY,
NULL SVC_NAME
FROM IVG_RQST R,
IVG_FRM F,
CLC_ENCNTR E,
ORG_SITE C,
IVG_RPT IR
WHERE R.IVG_FRM_ID = F.IVG_FRM_ID
AND R.CLC_ENCNTR_ID = E.CLC_ENCNTR_ID
AND E.ORG_SITE_ID = C.ORG_SITE_ID
AND R.IVG_RQST_ID = IR.IVG_RQST_ID
-- AND ((SELECT CASE
-- WHEN '{?Frequency}' = 'Yearly' THEN
-- (SELECT 1
-- FROM DUAL
-- WHERE TO_CHAR(IR.RPT_RCV_DATETIME, 'YYYY') = '{?Year}')
-- WHEN '{?Frequency}' = 'Monthly' THEN
-- (SELECT 1
-- FROM DUAL
-- WHERE TO_CHAR(IR.RPT_RCV_DATETIME, 'YYYY') = substr('{?Month}',1,4)
-- AND TO_CHAR(IR.RPT_RCV_DATETIME, 'MM') = substr('{?Month}',6,2)
--)
--
--WHEN '{?Frequency}' = 'Daily' THEN
-- (SELECT 1
-- FROM DUAL
-- WHERE TO_CHAR(IR.RPT_RCV_DATETIME, 'yyyy-mm-dd') = TO_CHAR({?Date}, 'yyyy-mm-dd'))
--
--
--
--WHEN '{?Frequency}' = 'User Specified' THEN
-- (SELECT 1
-- FROM DUAL
-- WHERE TRUNC(IR.RPT_RCV_DATETIME) BETWEEN
-- {?Start date} AND {?End date})
--
--
-- END CASE
-- FROM DUAL) = 1)
GROUP BY F.FRM_NAME, F.FRM_NUM, C.SITE_COD
UNION ALL
SELECT 'investigation request forms/disciplines' AS TYPE,
F.FRM_NAME,
F.FRM_NUM,
F.FRM_NUM as FORNUM,
NULL SITE_COD,
AVG(FLOOR(IR.RPT_RCV_DATETIME - R.RQST_DATETIME)) AS IRDAY,
NULL SVC_NAME
FROM IVG_RQST R, IVG_FRM F, IVG_RPT IR
WHERE R.IVG_FRM_ID = F.IVG_FRM_ID
AND R.IVG_RQST_ID = IR.IVG_RQST_ID
-- AND ((SELECT CASE
-- WHEN '{?Frequency}' = 'Yearly' THEN
-- (SELECT 1
-- FROM DUAL
-- WHERE TO_CHAR(IR.RPT_RCV_DATETIME, 'YYYY') = '{?Year}')
-- WHEN '{?Frequency}' = 'Monthly' THEN
-- (SELECT 1
-- FROM DUAL
-- WHERE TO_CHAR(IR.RPT_RCV_DATETIME, 'YYYY') = substr('{?Month}',1,4)
-- AND TO_CHAR(IR.RPT_RCV_DATETIME, 'MM') = substr('{?Month}',6,2)
--)
--
--WHEN '{?Frequency}' = 'Daily' THEN
-- (SELECT 1
-- FROM DUAL
-- WHERE TO_CHAR(IR.RPT_RCV_DATETIME, 'yyyy-mm-dd') = TO_CHAR({?Date}, 'yyyy-mm-dd'))
--
--
--
--WHEN '{?Frequency}' = 'User Specified' THEN
-- (SELECT 1
-- FROM DUAL
-- WHERE TRUNC(IR.RPT_RCV_DATETIME) BETWEEN
-- {?Start date} AND {?End date})
-- END CASE
-- FROM DUAL) = 1)
GROUP BY F.FRM_NAME, F.FRM_NUM
三:结果:
四:报表:
根据参数过滤记录:
根据参数 显示报表的某一部分:
五:公式:
把参数输入的 2012-12 处理为 DEC 2012
if(Split ({?Month},'-')[2]='01') then
'JAN' + " "+Split ({?Month},'-')[1]
else if(Split ({?Month},'-')[2]='02') then
'FEB' + " "+Split ({?Month},'-')[1]
else if(Split ({?Month},'-')[2]='03') then
'MAR' + " "+Split ({?Month},'-')[1]
else if(Split ({?Month},'-')[2]='04') then
'APR' + " "+Split ({?Month},'-')[1]
else if(Split ({?Month},'-')[2]='05') then
'MAY' + " "+Split ({?Month},'-')[1]
else if(Split ({?Month},'-')[2]='06') then
'JUNE' + " "+Split ({?Month},'-')[1]
else if(Split ({?Month},'-')[2]='07') then
'JULY' + " "+Split ({?Month},'-')[1]
else if(Split ({?Month},'-')[2]='08') then
'AUG' + " "+Split ({?Month},'-')[1]
else if(Split ({?Month},'-')[2]='09') then
'SEPT' + " "+Split ({?Month},'-')[1]
else if(Split ({?Month},'-')[2]='10') then
'OCT' + " "+Split ({?Month},'-')[1]
else if(Split ({?Month},'-')[2]='11') then
'NOV' + " "+Split ({?Month},'-')[1]
else if(Split ({?Month},'-')[2]='12') then
'DEC' + " "+Split ({?Month},'-')[1]