Hi i have a long query which goes something like this:SELECT e.LoginID, d.Name, e.Title As 'Worktitle', e.MaritalStatus, e.Gender, c.FirstName + ' ' + c.LastName AS 'FullName', c.EmailAddress, c.Phone, a.AddressLine1, a.AddressLine2, s.Name As 'ShiftName', p.Rate, p.PayFrequency, t.NameFROM EmployeePayHistory p INNER JOIN Employee e ON p.EmployeeID = e.EmployeeID INNER JOIN Contact c ON e.ContactID = c.ContactID INNER JOIN EmployeeDepartmentHistory ed ON ed.EmployeeID = e.EmployeeID INNER JOIN Shift s ON s.ShiftID = ed.ShiftID INNER JOIN Department d ON d.DepartmentID = ed.DepartmentID INNER JOIN EmployeeAddress ea ON ea.EmployeeID = e.EmployeeID INNER JOIN Address a ON a.AddressID = ea.AddressID INNER JOIN StateProvince sp ON sp.StateProvinceID = a.StateProvinceID INNER JOIN SalesTerritory t ON sp.TerritoryID = t.TerritoryIDWHERE ed.EndDate IS NULLORDER BY e.EmployeeID
My problem is that in EmployeePayHistory there are rows repeated for the same employees, so for example, employee with ID of 2 has 3 rows and each row has different information and there's a RateChangeDate column so I want to select only the most recent RateChangeDate. But I don't want this column to appear, how do i do this?