mysql常用统计

SELECT
  t.*,
  b.name
FROM
  (SELECT
     count(1)    NUM,
     SUM(AMOUNT) AMOUNT,
     merchant_id
   FROM payment_flow
   WHERE create_time > '2022-12-16'
         AND create_time < '2022-12-17' AND status = 'SUCCESS'

   GROUP BY merchant_id) AS t
  LEFT JOIN merchant b ON t.merchant_id = b.id
ORDER BY T.NUM DESC;
select date,sum(success_amount),sum(success_count)/sum(total_count) as rate FROM payment_statistics_day where  merchant_id='62eb7a6e9cf6691757afef0b' group by date order by date desc limit 60;

发表评论

邮箱地址不会被公开。