Advertisement
festinko

Untitled

Sep 29th, 2022
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.49 KB | None | 0 0
  1. SELECT
  2.     userSMSRefill,
  3.     count(DISTINCT p.userID) usersCount,
  4.     ROUND(SUM(paymentAmount)) revenue
  5.    
  6. FROM
  7.     payments p
  8.     LEFT JOIN users u
  9.     on p.userID = u.userID
  10.    
  11. WHERE
  12.  
  13. paymentDateTime > '2022-07-13 00:00:01'
  14. AND p.userID IN (
  15.     SELECT
  16.                  userID
  17.                 FROM
  18.                         alertcontacts
  19.                        
  20.                 WHERE
  21.                         alertContactType IN (8,14)
  22.                         AND alertContactStatus = 2
  23.                        
  24.                 GROUP BY
  25.                                 userID
  26.                 ORDER BY
  27.                         userID)
  28. AND paymentPeriod = 0
  29.  
  30. GROUP BY
  31.     userSMSRefill
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement