I have a table in SQL Server.
ID PID LASTMODIFIED REASON
1 1 01/01/2011 XYZ
2 1 04/01/2011 XYY
3 2 05/01/2011 ZZZ
4 2 03/01/2011 ABC
I want to select the rows based on MAX(LASTMODIFIED) for each PID. For EX, the select should return the following:
ID PID LASTMODIFIED REASON
2 1 04/01/2011 XYY
3 2 05/01/2011 ZZZ
Pelase help me with the SQL statement. Thank you.
1 Answer