Guest User

Untitled

a guest
Jun 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. cust_name,sales_count,day_count
  2. cust_a,100,3
  3. cust_a,200,5
  4. cust_a,150,7
  5. cust_a,120,1
  6. cust_a,180,10
  7. cust_a,100,8
  8. cust_b,20,3
  9. cust_b,10,4
  10. cust_b,50,6
  11. cust_b,60,8
  12. cust_b,15,9
  13.  
  14. cust_name,sales_count,day_count
  15. cust_a,280,last_14
  16. cust_a,450,last_7
  17. cust_b,85,last_14
  18. cust_b,80,last_7
  19.  
  20. select cust_name,
  21. sum(case when day_count > 7 then count(sales_count) else 0 end) as count_14,
  22. sum(case when day_count < 7 then count(pendo_visitor_id) else 0 end) as count_7
  23. from sales
  24. group by cust_name;
Add Comment
Please, Sign In to add comment