We help IT Professionals succeed at work.

Exclude specific records from query

In the attached code I added...
     AND (h.JobCode <> 3 OR h.JobCode <>5)
What I want is to not include the record if the JobCode for that record is 3 or if the JobCode is 5.  The query runs with my code but the records with JobCode 3 and 5 are still being included. Can you please show me what I am doing wrong.
Thanks,

SELECT     
	u.UserName as Supervisor, 
	'Begin' as 'Type', 
	a.EmployeeId, 
	a.Name, 
	a.Expected, 
	a.Actual, 
	CONVERT(varchar, FLOOR(a.Tardy / 60.0)) + ':' + RIGHT('0' + CONVERT(varchar, a.Tardy % 60),2) AS HrMin,
	n.ShiftNote
FROM    
    (SELECT     
		CONVERT(varchar(20), s.TimeIn, 100) AS Expected, 
		s.TimeIn, 
		l.LastName + ', ' + l.FirstName AS Name, 
		l.EmployeeId, 
		l.ManagerUID,
		CONVERT(varchar(20), MIN(h.TimeIn), 100) AS Actual, 
			CASE WHEN s.TimeIn < MIN(h.TimeIn) THEN DATEDIFF(MINUTE, s.TimeIn, ISNULL(MIN(h.TimeIn), s.TimeIn)) END AS Tardy, 
		MIN(h.RecordId) AS RecordId
     FROM dbo.EmployeeHours AS h 
	INNER JOIN dbo.EmployeeSchedules AS s ON h.EmployeeId = s.EmployeeId 
		AND DATEADD(day, 0, DATEDIFF(DAY, 0, s.TimeIn)) = DATEADD(DAY, 0, DATEDIFF(DAY, 0,h.TimeIn)) 
	INNER JOIN dbo.EmployeeList AS l ON s.Company = l.Company AND s.EmployeeId = l.EmployeeId
     WHERE (l.Suspend = 0)  AND (h.JobCode <> 3 OR h.JobCode <>5) AND (DATEADD(DAY, 0, DATEDIFF(DAY, 0, h.TimeIn)) 
     BETWEEN @From AND @To)AND Class in (2,4,6,7) 
GROUP BY l.EmployeeId, l.ManagerUID, s.TimeIn, l.LastName, l.FirstName) AS a 
	LEFT OUTER JOIN dbo.UserList AS u ON a.ManagerUID = u.UID 
	LEFT OUTER JOIN dbo.EmployeeShiftNotes AS n ON a.RecordId = n.RecordId AND a.EmployeeId = n.EmployeeId
WHERE (a.Tardy >= 0)  
 AND (u.UserName = @Supervisor)
 AND u.Company = 1

Open in new window

Comment
Watch Question

SQL Server Data Dude
Most Valuable Expert 2013
Author of the Year 2015
Commented:
AND h.JobCode NOT IN (3, 5)

or

AND (h.JobCode <> 3 AND h.JobCode <>5)

Author

Commented:
They both worked!  Thank you so much for your quick response and great code!
Jim HornSQL Server Data Dude
Most Valuable Expert 2013
Author of the Year 2015

Commented:
Thanks for the grade.  Good luck with your project.  -Jim