首页 > 代码库 > MySQL学习_计算用户支付方式占比_20161104
MySQL学习_计算用户支付方式占比_20161104
计算用户支付方式占比
SELECT b.*#根据城市ID 年月排序 FROM ( SELECT a.* FROM ( #纵向合并 SELECT b1.ID,a1.城市,a1.收款方式,DATE_FORMAT(a1.确认时间,"%Y%m") AS 年月,SUM(a1.金额) AS 收款方式金额 FROM `a029_collectionment` AS a1 LEFT JOIN `a000_city` AS b1 ON a1.城市=b1.城市 WHERE a1.确认时间>"2016-01-01" AND a1.确认时间<CURRENT_DATE AND a1.收款方式="现金" GROUP BY a1.城市,DATE_FORMAT(a1.确认时间,"%Y%m") ) AS a UNION ALL ( SELECT d1.ID,c1.城市,c1.收款方式,DATE_FORMAT(c1.支付时间,"%Y%m") AS 年月,SUM(c1.金额) AS 收款方式金额 FROM `a031_order_paypal` AS c1 LEFT JOIN `a000_city` AS d1 ON d1.城市=c1.城市 WHERE c1.支付时间>"2016-01-01" AND c1.支付时间<CURRENT_DATE GROUP BY c1.城市,c1.收款方式,DATE_FORMAT(c1.支付时间,"%Y%m") ) ) AS b ORDER BY b.ID,b.年月
MySQL学习_计算用户支付方式占比_20161104
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。