mysql 中unionall 使用
SELECT
pay_id,
invoice_num,
task_name,
pay_priority,
core_enterprise_name,
financial_institutions_name,
suppliers_name,
item_company_name,
account_receivable,
task_user_uuid,
biz_uuid,
task_uuid,
task_id
FROM
(
SELECT
d.pay_id,
COUNT(g.uuid) AS invoice_num,
e.task_name,
d.pay_priority,
f.core_enterprise_name,
i.financial_institutions_name,
h.suppliers_name,
j.item_company_name,
d.account_receivable,
b.user_uuid AS task_user_uuid,
c.biz_uuid,
a.task_id,
e.uuid AS task_uuid
FROM
bpm_activity a,
bpm_task_user b,
bpm_process_instance c,
biz_pay_comfirm_info d,
biz_document_task_info e,
biz_core_enterprise f,
biz_financial_institutions i,
biz_suppliers h,
biz_item_company j,
biz_invoice_info g
WHERE
a.ACTIVITY_NAME IN (
'单证线上初审',
'单证线上复审'
)
AND c.process_name = 'BusinessModel2.0/保理业务线上审核流程'
AND a.task_id = b.task_id
AND a.instance_id = c.instance_id
AND a.`status` = '已领取'
AND c.biz_uuid = d.uuid
AND f.uuid = d.core_enterprise_id
AND i.uuid = d.financial_institutions_id
AND h.uuid = d.suppliers_id
AND j.uuid = d.item_company_id
AND a.ACTIVITY_NAME = e.activity_name
AND c.process_name = e.process_name
AND d.core_enterprise_id = e.core_enterprise_id
AND d.financial_institutions_id = e.financial_institutions_id
AND d.signing_body_id = e.signing_body_id
AND FROM_UNIXTIME(
a.claim_time / 1000,
'%Y-%m-%d'
) >= '2019-03-01'
AND FROM_UNIXTIME(
a.claim_time / 1000,
'%Y-%m-%d'
) <= '2019-03-14'
AND b.user_uuid = 'u1029'
AND e.uuid = ' DT1002'
AND d.uuid = g.pay_id
AND a.sys_status = 1
AND b.sys_status = 1
AND c.sys_status = 1
AND d.sys_status = 1
AND e.sys_status = 1
AND f.sys_status = 1
AND g.sys_status = 1
AND i.sys_status = 1
AND j.sys_status = 1
GROUP BY
c.biz_uuid
UNION ALL
SELECT
d.pay_id,
COUNT(g.uuid) AS invoice_num,
e.task_name,
d.pay_priority,
f.core_enterprise_name,
i.financial_institutions_name,
h.suppliers_name,
j.item_company_name,
d.account_receivable,
b.user_uuid AS task_user_uuid,
c.biz_uuid,
e.uuid AS task_uuid,
a.task_id
FROM
bpm_activity a,
bpm_task_user b,
bpm_process_instance c,
biz_pay_comfirm_info d,
biz_document_task_info e,
biz_core_enterprise f,
biz_financial_institutions i,
biz_suppliers h,
biz_item_company j,
biz_invoice_info g,
biz_factoring_reception k
WHERE
a.ACTIVITY_NAME IN (
'单证线下纸质审核',
'项目单证线下纸质审核'
)
AND c.process_name IN (
'BusinessModel2.0/保理业务线下审核流程',
'BusinessModel2.0/保理项目公司资料线下审核流程'
)
AND a.task_id = b.task_id
AND a.instance_id = c.instance_id
AND a.`status` = '已领取'
AND c.biz_uuid = k.uuid
AND f.uuid = d.core_enterprise_id
AND i.uuid = d.financial_institutions_id
AND h.uuid = d.suppliers_id
AND j.uuid = d.item_company_id
AND a.ACTIVITY_NAME = e.activity_name
AND c.process_name = e.process_name
AND d.core_enterprise_id = e.core_enterprise_id
AND d.financial_institutions_id = e.financial_institutions_id
AND d.signing_body_id = e.signing_body_id
AND FROM_UNIXTIME(
a.claim_time / 1000,
'%Y-%m-%d'
) >= '2019-03-01'
AND FROM_UNIXTIME(
a.claim_time / 1000,
'%Y-%m-%d'
) <= '2019-03-14'
AND b.user_uuid = 'u1029'
AND e.uuid = ' DT1002'
AND d.uuid = g.pay_id
AND k.biz_id = d.uuid
AND a.sys_status = 1
AND b.sys_status = 1
AND c.sys_status = 1
AND d.sys_status = 1
AND e.sys_status = 1
AND f.sys_status = 1
AND g.sys_status = 1
AND i.sys_status = 1
AND j.sys_status = 1
AND k.sys_status = 1
GROUP BY
c.biz_uuid
UNION ALL
SELECT
k.agreement_no AS pay_id,
0 AS invoice_num,
e.task_name,
'' AS pay_priority,
f.core_enterprise_name,
i.financial_institutions_name,
h.suppliers_name,
'' AS item_company_name,
'' AS account_receivable,
b.user_uuid AS task_user_uuid,
e.uuid AS task_uuid,
c.biz_uuid,
a.task_id
FROM
bpm_activity a,
bpm_task_user b,
bpm_process_instance c,
biz_first_contract d,
biz_core_enterprise f,
biz_document_task_info e,
biz_financial_institutions i,
biz_suppliers h,
biz_framework_agreement k
WHERE
a.ACTIVITY_NAME = '单证线上审核'
AND c.process_name = 'BusinessModel2.0/首次准入线上审核流程'
AND a.`status` = '已领取'
AND a.task_id = b.task_id
AND a.instance_id = c.instance_id
AND c.biz_uuid = d.uuid
AND f.uuid = d.core_enterprise_id
AND i.uuid = d.financial_institutions_id
AND h.uuid = d.suppliers_id
AND d.agreement_id = k.uuid
AND e.process_name = c.process_name
AND e.activity_name = a.ACTIVITY_NAME
AND e.core_enterprise_id = d.core_enterprise_id
AND e.financial_institutions_id = d.financial_institutions_id
AND e.signing_body_id = d.signing_body_id
AND A.sys_status = 1
AND B.sys_status = 1
AND C.sys_status = 1
AND D.sys_status = 1
AND F.sys_status = 1
AND I.sys_status = 1
AND H.sys_status = 1
AND e.sys_status = 1
AND k.sys_status = 1
AND FROM_UNIXTIME(
a.claim_time / 1000,
'%Y-%m-%d'
) >= '2019-03-01'
AND FROM_UNIXTIME(
a.claim_time / 1000,
'%Y-%m-%d'
) <= '2019-03-14'
AND b.user_uuid = 'u1029'
AND e.uuid = 'DT1002'
GROUP BY
c.biz_uuid
UNION ALL
SELECT
k.agreement_no AS pay_id,
0 AS invoice_num,
e.task_name,
'' AS pay_priority,
f.core_enterprise_name,
i.financial_institutions_name,
h.suppliers_name,
'' AS item_company_name,
'' AS account_receivable,
b.user_uuid AS task_user_uuid,
e.uuid AS task_uuid,
c.biz_uuid,
a.task_id
FROM
bpm_activity a,
bpm_task_user b,
bpm_process_instance c,
biz_first_contract d,
biz_core_enterprise f,
biz_document_task_info e,
biz_financial_institutions i,
biz_suppliers h,
biz_framework_agreement k,
biz_admittance_reception g
WHERE
a.ACTIVITY_NAME = '单证审核纸质资料'
AND c.process_name = 'BusinessModel2.0/首次准入线下审核流程'
AND a.`status` = '已领取'
AND a.task_id = b.task_id
AND a.instance_id = c.instance_id
AND f.uuid = d.core_enterprise_id
AND i.uuid = d.financial_institutions_id
AND h.uuid = d.suppliers_id
AND d.agreement_id = k.uuid
AND e.process_name = c.process_name
AND e.activity_name = a.ACTIVITY_NAME
AND e.core_enterprise_id = d.core_enterprise_id
AND e.financial_institutions_id = d.financial_institutions_id
AND e.signing_body_id = d.signing_body_id
AND g.uuid = c.biz_uuid
AND g.biz_id = d.uuid
AND A.sys_status = 1
AND B.sys_status = 1
AND C.sys_status = 1
AND d.sys_status = 1
AND F.sys_status = 1
AND I.sys_status = 1
AND H.sys_status = 1
AND e.sys_status = 1
AND k.sys_status = 1
AND g.sys_status = 1
AND FROM_UNIXTIME(
a.claim_time / 1000,
'%Y-%m-%d'
) >= '2019-03-01'
AND FROM_UNIXTIME(
a.claim_time / 1000,
'%Y-%m-%d'
) <= '2019-03-14'
AND b.user_uuid = 'u1029'
AND e.uuid = 'DT1002'
GROUP BY
c.biz_uuid
) x
GROUP BY
biz_uuid