The SQL Server query I have is:
SELECT
ep.employeeID, ep.punchdate, rc.creditAmount
FROM
EmployeePunch ep
INNER JOIN
ResponderCredit rc ON rc.employeeID = ep.employeeID AND
rc.punchdate = rc.creditdate
ORDER BY ep.employeeID
and get a result set:
EmployeeID Date CreditAmount
----------- ------- --------------
5 01/01/2007 5
5 03/01/2007 7
5 04/22/2007 15
6 01/01/2007 3
6 01/12/2007 4
And I want to group by EmployeeID and Credit amount. The catch is that I need the change in the Credit Amount between the max and min date so:
EmployeeID CreditAmount
----------- --------------
5 10
6 1
How can I do this?