MySQL WITH ROLLUP

SELECT 
  IFNULL(Sdate,"总计") AS Sdate ,
COUNT(DISTINCT orderDeputyID) AS '下单数',
SUM(ticketCount) AS '票张数',
COUNT(DISTINCT payorderDeputyID ) '支付订单数',
SUM(payticketCount) '支付票单数',
COUNT(DISTINCT orderDeputyID)-(COUNT(DISTINCT payorderDeputyID)) '未支付订单数',
SUM(ticketCount)-SUM(payticketCount) '未支付票单数'
FROM
  T_withrowup
GROUP BY Sdate WITH ROLLUP

你可能感兴趣的:(数据库,MySQL)