Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.99 KB | None | 0 0
  1. SELECT     u.UniqueID AS UserID, u.Name AS LastName, u.FirstName, f.Name AS CompanyName, f.Address AS CompanyAddress, f.City AS CompanyCity,
  2.                       s.StateCode AS CompanyState, f.Zip AS CompanyZip, f.Phone AS CompanyPhone, f.Email AS CompanyEmail, p.ProgramName, CONVERT(varchar(10), atp.DateExpire,
  3.                       101) AS DateExpire
  4. FROM         AssignedTrainingPrograms AS atp INNER JOIN
  5.                       Users AS u ON atp.UserID = u.ID INNER JOIN
  6.                       Facilities AS f ON f.ID = u.FacilityID INNER JOIN
  7.                       States AS s ON s.StateID = f.StateID INNER JOIN
  8.                       TrainingPrograms AS p ON p.ProgramID = atp.ProgramID
  9. WHERE     (atp.DateExpire BETWEEN GETDATE() AND DATEADD(dd, 7, GETDATE())) AND (atp.UserID NOT IN
  10.                           (SELECT     UserID
  11.                             FROM          AssignedTrainingPrograms
  12.                             WHERE      (DateAssigned LIKE GETDATE())))
  13. ORDER BY atp.DateExpire
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement