Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. email address|product code
  2. garry123@gmail.com |A123A
  3. garry123@gmail.com |AB263
  4. ada121@hotmail.com |45632A
  5. ada121@hotmail.com |78YU
  6. garry123@gmail.com |6543D
  7.  
  8. garry123@gmail.com|A123A,AB263,6543D
  9. ada121@hotmail.com|45632A,78YU
  10.  
  11. SELECT
  12. c.EmailAddress,
  13. od.concat(productcode) as Product_SKU
  14. FROM
  15. OrderDetails od
  16. JOIN Orders o
  17. ON od.OrderID = o.OrderID
  18. JOIN Customers c
  19. ON c.CustomerID=o.CustomerID
  20. WHERE
  21. o.OrderDate BETWEEN 01/01/2016 AND getdate()
  22. GROUP BY c.EmailAddress
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement