From surenkid, 1 Year ago, written in MySQL.
Embed
  1. -- 总订单
  2. CREATE TEMPORARY TABLE IF NOT EXISTS sorder
  3. SELECT id,memberid,wechatorderid,mobile,`name`,money,`time`,debug_status FROM `smwx_order`
  4. WHERE `time`>'2018-11-21 11:59:59' AND `status` = 1 AND `name` like 'vinistyle十周年感恩礼盒%';
  5. -- 长街支付订单
  6. CREATE TEMPORARY TABLE IF NOT EXISTS schanpay
  7. SELECT DISTINCT orderid,wechatorderid,trade_amount,chanpayorderid,create_time,`status` FROM `smwx_chanpay_order`
  8. WHERE `create_time`>'2018-11-21 11:59:59';
  9. -- 结合长街支付订单
  10. SELECT sorder.id
  11. ,sorder.`name`
  12. ,sorder.`money`
  13. ,sorder.`debug_status`
  14. ,schanpay.`trade_amount`
  15. ,schanpay.`chanpayorderid`
  16. ,schanpay.`create_time`
  17. FROM sorder
  18. LEFT JOIN schanpay ON sorder.id = schanpay.orderid;
  19. -- 查询各种订单数量
  20. SELECT `name`,`debug_status`, `trade_amount`,count(*)
  21. from sall
  22. GROUP BY `name`,`debug_status`, `trade_amount`;