Advertisement
festinko

Untitled

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