I have this query there I want get all empids’ who didn’t not handle orders on February 12 ,
2008
Select Distinct E.empid, lastname, firstname
From HR.Employees as E
INNER JOIN Sales.Orders as O
ON E.empid = O.empid
Where O.orderdate <> Convert(datetime,'02/12/2008',101)
using NOT IN, EXISTS or set operators is not applicable can somebody get me a genuine solution and explanation also
One way to do this is to use a left outer join:
If there is a match between employees and orders on the date, then the
whereclause ignores those records.This query is rephrasing your logic. You say “I want get all empids’ who didn’t not handle orders on February 12 , 2008”. The way this works is it actually matches the employees to orders on that date. However, because it uses a
left outer join, the match leaves a NULL when there is no match. These are the ones that you want.In a sense, this query answers the equivalent question, phrased as “I want all empids that fail to match an order on such-and-such a date.”