I’m using a SQL Server 2012 database and I’m trying to retrieve all employee ids’ and there first names who didn’t handle an order on February 2 2008 and I ran into such issue
Select
Distinct E.empid, E.firstname
from
HR.Employees E
where
E.empid in (Select empid
From Sales.Orders As S
where orderdate <> '20080212')
This query returns all employee ids’ and first name but this query returns only employ ids’ who have handled the order on that day
Select Distinct E.empid, E.firstname
from HR.Employees E
where E.empid in (Select empid
From Sales.Orders As S
where orderdate = '20080212')
I understand that problem is in filtering orderdate but can you tell me guys what am I doing wrong
I’ll assume this is a DataTime column not a Date column. As a DateTime you are asking for employees who didn’t take an order at one instant in time not across the whole day. There are many variants to handle this but the one I would use is