mySql中union all 及max,ifnull用法
select
ifnull(max(d.orderNum),0) totalNum,
ifnull(max(d.money),0) totalMoney,
ifnull(max(d.unpayOrderNum),0) unpaidNum,
ifnull(max(d.unpayMoney),0) unpaidMoney,
ifnull(max(d.payOrderNum),0) paidNum,
ifnull(max(d.PayMoney),0) paidMoney from
(SELECT
count(1) orderNum,
sum(money) money,
'' unpayOrderNum,
'' unpayMoney,
'' payOrderNum,
'' PayMoney
from
os_order_form
where del_flag = 0
UNION ALL
SELECT
'' orderNum,
'' money,
count(1) unpayOrderNum,
sum(money) unpayMoney,
'' payOrderNum,
'' PayMoney
from
os_order_form
where
del_flag = 0
and
pay_time is null
UNION ALL
SELECT
'' orderNum,
'' money,
'' unpayOrderNum,
'' unpayMoney,
count(1) payOrderNum,
sum(money) PayMoney
from
os_order_form