怎么查询从2021年1月1号到9月30被退回过的单据数量
2021-10-13 15:17:35
335次阅读
1个回答
怎么查询从2021年1月1号到9月30被退回过的单据数量
0
2021-10-13 15:22:01
最佳答案
SELECT
TT.FTYPE NAME,
YTYPE RISK_TYPE,
COUNT(NUM) TOTAL
FROM (
SELECT
'退回' FTYPE,
'退回' FTYPE_NAME,
'支出' YTYPE,
1 NUM
FROM
PAYOUT_LOAN PL,
SYS_AUDIT_LOG SAL
WHERE
PL.LOAN_ID = SAL.BUSINESS_ID
AND PL.FINANCEAL_YEAR = '2021'
AND PL.LESSEE_CODE = 'nxhzzzq_jtyst'
AND SAL.AUDIT_LOG_STATE = '已退回'
AND SAL.OPERATE_TIME < '2021-09-30 00:00:00'
UNION ALL
SELECT
'退回' FTYPE,
'退回' FTYPE_NAME,
'支出' YTYPE,
1 NUM
FROM
PAYOUT_PAYMENT PP,
SYS_AUDIT_LOG SAL
WHERE
PP.PAYMENT_ID = SAL.BUSINESS_ID
AND PP.FINANCEAL_YEAR = '2021'
AND PP.LESSEE_CODE = 'nxhzzzq_jtyst'
AND SAL.AUDIT_LOG_STATE = '已退回'
AND SAL.OPERATE_TIME < '2021-09-30 00:00:00'
UNION ALL
SELECT
'退回' FTYPE,
'退回' FTYPE_NAME,
'采购' YTYPE,
1 NUM
FROM
PURCH_PURCHASE_MANAGE PPM,
SYS_AUDIT_LOG SAL
WHERE
PPM.PURCHASE_MANAGE_ID = SAL.BUSINESS_ID
AND PPM.FINANCEAL_YEAR = '2021'
AND PPM.LESSEE_CODE = 'nxhzzzq_jtyst'
AND SAL.AUDIT_LOG_STATE = '已退回'
AND SAL.OPERATE_TIME < '2021-09-30 00:00:00'
UNION ALL
SELECT
'退回' FTYPE,
'退回' FTYPE_NAME,
'合同' YTYPE,
1 NUM
FROM
CONT_CONTRACT CC,
SYS_AUDIT_LOG SAL
WHERE
CC.CONTRACT_ID = SAL.BUSINESS_ID
AND CC.FINANCEAL_YEAR = '2021'
AND CC.LESSEE_CODE = 'nxhzzzq_jtyst'
AND SAL.AUDIT_LOG_STATE = '已退回'
AND SAL.OPERATE_TIME < '2021-09-30 00:00:00'
) TT
GROUP BY
TT.FTYPE,
TT.FTYPE_NAME,
TT.FTYPE NAME,
YTYPE RISK_TYPE,
COUNT(NUM) TOTAL
FROM (
SELECT
'退回' FTYPE,
'退回' FTYPE_NAME,
'支出' YTYPE,
1 NUM
FROM
PAYOUT_LOAN PL,
SYS_AUDIT_LOG SAL
WHERE
PL.LOAN_ID = SAL.BUSINESS_ID
AND PL.FINANCEAL_YEAR = '2021'
AND PL.LESSEE_CODE = 'nxhzzzq_jtyst'
AND SAL.AUDIT_LOG_STATE = '已退回'
AND SAL.OPERATE_TIME < '2021-09-30 00:00:00'
UNION ALL
SELECT
'退回' FTYPE,
'退回' FTYPE_NAME,
'支出' YTYPE,
1 NUM
FROM
PAYOUT_PAYMENT PP,
SYS_AUDIT_LOG SAL
WHERE
PP.PAYMENT_ID = SAL.BUSINESS_ID
AND PP.FINANCEAL_YEAR = '2021'
AND PP.LESSEE_CODE = 'nxhzzzq_jtyst'
AND SAL.AUDIT_LOG_STATE = '已退回'
AND SAL.OPERATE_TIME < '2021-09-30 00:00:00'
UNION ALL
SELECT
'退回' FTYPE,
'退回' FTYPE_NAME,
'采购' YTYPE,
1 NUM
FROM
PURCH_PURCHASE_MANAGE PPM,
SYS_AUDIT_LOG SAL
WHERE
PPM.PURCHASE_MANAGE_ID = SAL.BUSINESS_ID
AND PPM.FINANCEAL_YEAR = '2021'
AND PPM.LESSEE_CODE = 'nxhzzzq_jtyst'
AND SAL.AUDIT_LOG_STATE = '已退回'
AND SAL.OPERATE_TIME < '2021-09-30 00:00:00'
UNION ALL
SELECT
'退回' FTYPE,
'退回' FTYPE_NAME,
'合同' YTYPE,
1 NUM
FROM
CONT_CONTRACT CC,
SYS_AUDIT_LOG SAL
WHERE
CC.CONTRACT_ID = SAL.BUSINESS_ID
AND CC.FINANCEAL_YEAR = '2021'
AND CC.LESSEE_CODE = 'nxhzzzq_jtyst'
AND SAL.AUDIT_LOG_STATE = '已退回'
AND SAL.OPERATE_TIME < '2021-09-30 00:00:00'
) TT
GROUP BY
TT.FTYPE,
TT.FTYPE_NAME,
TT.YTYPE
自行替换LESSEE_CODE
共1条
1
- 0 回答
- 0 粉丝
- 0 关注