Advertisement
festinko

Untitled

Sep 8th, 2022
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.32 KB | None | 0 0
  1. SELECT
  2.     YEAR(paymentDateTime) AS year,
  3.     MONTH(paymentDateTime) AS month,
  4.     paymentPeriod,
  5.     COUNT(DISTINCT userID) customersWithPayment,
  6.     ROUND(SUM(paymentAmount),2) revenue
  7.    
  8. FROM
  9.     payments
  10.  
  11. WHERE
  12.     paymentStatus = 1
  13.     AND paymentType = 2
  14.    
  15. GROUP BY
  16.     year, month, paymentPeriod
  17.    
  18. ORDER BY
  19.     year DESC,
  20.     month DESC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement