Advertisement
festinko

Untitled

Dec 6th, 2022
799
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.00 KB | None | 0 0
  1. WITH customersWithoutPSPCustomDomain as (
  2.         SELECT
  3.             p.userID
  4.            
  5.             FROM
  6.               `uptimerobot-001.ur.payments` p
  7.            
  8.             WHERE
  9.               paymentPeriod IN (1,12)
  10.               AND paymentStatus = 1
  11.               AND  p.userID IN (
  12.                       /*users w/o psp on custom domain*/
  13.                       SELECT
  14.                         userID
  15.  
  16.                       FROM
  17.                         `uptimerobot-001.ur.psp`
  18.  
  19.                       WHERE
  20.                         pspCustomDomain IS NULL
  21.                         OR pspCustomDomain= ''
  22.  
  23.                       GROUP BY
  24.                       userID)
  25.  
  26.             GROUP BY
  27.               p.userID)
  28.  
  29. SELECT
  30.   userIsProPlan,
  31.   COUNT (DISTINCT customersWithoutPSPCustomDomain.userID) usersCount
  32.  
  33. FROM
  34.   customersWithoutPSPCustomDomain
  35. LEFT JOIN
  36.   `uptimerobot-001.ur.users` u
  37.  
  38. ON
  39.   customersWithoutPSPCustomDomain.userID = u.userID
  40.  
  41. GROUP BY
  42.   userIsProPlan
  43.    
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement