Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. select customer
  2. ,count (*) as contacts
  3.  
  4. from mytable
  5.  
  6. where contact_date >= current_date() - 90
  7.  
  8. group by customer
  9. ;
  10.  
  11. MarketingEmails( CustomerID, Email, SentTo, SentDate );
  12.  
  13.  
  14. SELECT CustomerId,
  15. Email,
  16. SentTo,
  17. SentDate,
  18. COUNT(1) OVER ( PARTITION BY CustomerID,Email ORDER BY SentDate ) AS
  19. CountofContactsbyCustomerEmail
  20. FROM MarketingEmails
  21. WHERE DATEDIFF(dd,GETDATE(),TO_DATE( SentDate ) ) >= 90;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement