SQL合并
Posted Gemini-Boy
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQL合并相关的知识,希望对你有一定的参考价值。
SELECT
idName,SUM(Money),SUM(Revenue)
FROM
(
SELECT agentID AS idName,SUM(totalMoney) AS Money,0 AS Revenue FROM lm_agent_finance_webstat GROUP BY agentID
UNION ALL
SELECT agentID AS idName,0 AS Money,SUM(totalRevenue) AS Revenue FROM lm_agent_financestat GROUP BY agentID
) a
GROUP BY
idName
idName,SUM(Money),SUM(Revenue)
FROM
(
SELECT agentID AS idName,SUM(totalMoney) AS Money,0 AS Revenue FROM lm_agent_finance_webstat GROUP BY agentID
UNION ALL
SELECT agentID AS idName,0 AS Money,SUM(totalRevenue) AS Revenue FROM lm_agent_financestat GROUP BY agentID
) a
GROUP BY
idName
以上是关于SQL合并的主要内容,如果未能解决你的问题,请参考以下文章