What would the syntax be to check the SQL statement that is provided? I am trying to check if an employee is allowed to check out any videos or maybe restrict the list that displays to only employees that are eligible to checkout videos. Any help is appreciated.
SELECT t .*
FROM (SELECT Employees.EmployeeID, Employees.Last_name, Employees.First_name, VideoList.video_name, Detail.out_date, Detail.in_date, Role,
COUNT(*) OVER (Partition BY Employees.EmployeeId) AS CountNotCheckedIn
FROM Employees INNER JOIN
Detail ON Employees.EmployeeID = Detail.EmployeeID INNER JOIN
VideoList ON Detail.VideoID = VideoList.VideoID
WHERE Detail.In_Date IS NULL AND Detail.Out_Date IS NOT NULL) t
WHERE t .CountNotCheckedIn = 2 AND Role <> '2'