• Hi!

    I don't understand how the condition AND o.OrderDate > DATEADD(month, -4, CURRENT_TIMESTAMP) in SQL Query #4 works. For me it seems it is to eliminate the employees with no appropriate order attached.

    Have I overlooked something?

    To have 100% same behaviour, I use:

    SELECT e.Name AS SalesRep, c.Name AS Customer, o.OrderDate

    FROM dbo.Customers AS c

    INNER JOIN dbo.Orders AS o

    ON c.CustomerID = o.CustomerID

    AND o.OrderDate > DATEADD(month, -4, CURRENT_TIMESTAMP)

    RIGHT JOIN dbo.Employees AS e

    ON e.EmployeeID = c.SalesRep

    WHERE e.Position = 'SalesRep';



    See, understand, learn, try, use efficient
    © Dr.Plch