Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. Service_ID Service_RNO Cust_Name Agrement_ID Cust_ID Service_Date Next_Service
  2. 4 004 customer1 35 16 2016-01-03 2016-02-02
  3. 5 005 customer2 35 16 2016-02-03 2016-03-01
  4.  
  5. SELECT dbo.Service.Service_ID,
  6. dbo.Service.Service_RNO,
  7. dbo.Customer.Cust_Name,
  8. dbo.Service.Agrement_ID,
  9. dbo.Customer.Cust_ID,
  10. dbo.Service.Service_Date,
  11. dbo.Service.Next_Service
  12. FROM dbo.Service
  13. INNER JOIN dbo.Customer ON dbo.Service.Cust_ID = dbo.Customer.Cust_ID
  14. WHERE Next_Service between '2016-02-01' and '2016-02-06'
  15. AND Next_Service not in (
  16. SELECT Dateadd(d, 1, Service_Date)
  17. FROM Service s
  18. WHERE s.Cust_ID = dbo.Customer.Cust_ID
  19. )
  20. ORDER BY Next_Service
  21.  
  22. SELECT dbo.Service.Service_ID,
  23. dbo.Service.Service_RNO,
  24. dbo.Customer.Cust_Name,
  25. dbo.Service.Agrement_ID,
  26. dbo.Customer.Cust_ID,
  27. dbo.Service.Service_Date,
  28. dbo.Service.Next_Service
  29. FROM dbo.Service
  30. INNER JOIN dbo.Customer ON dbo.Service.Cust_ID = dbo.Customer.Cust_ID
  31. WHERE Next_Service between '2016-02-01' and '2016-02-06'
  32. AND Next_Service not in (
  33. SELECT Dateadd(d, 1, Service_Date)
  34. FROM Service s
  35. WHERE s.Cust_ID = dbo.Customer.Cust_ID
  36. )
  37. or Next_Service not in (
  38. SELECT Dateadd(d, 1, Service_Date)
  39. FROM Service s
  40. WHERE s.Cust_ID = dbo.Customer.Cust_ID
  41. )
  42. ORDER BY Next_Service
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement