Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select customer
- ,count (*) as contacts
- from mytable
- where contact_date >= current_date() - 90
- group by customer
- ;
- MarketingEmails( CustomerID, Email, SentTo, SentDate );
- SELECT CustomerId,
- Email,
- SentTo,
- SentDate,
- COUNT(1) OVER ( PARTITION BY CustomerID,Email ORDER BY SentDate ) AS
- CountofContactsbyCustomerEmail
- FROM MarketingEmails
- WHERE DATEDIFF(dd,GETDATE(),TO_DATE( SentDate ) ) >= 90;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement