Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
p_id date test_name 1001 01/02/05 A 1001 01/02/05 B1001 02/28/05 A1002 02/01/05 B1002 02/01/05 C1003 01/12/05 C1003 01/30/05 A1003 02/15/05 C
I would like to return a list of people who took the same test in a different date and it's maximum date.
The result should look like:P_id date test1001 02/28/05 A1003 02/15/05 C
andy8979
Starting Member
36 Posts
Posted - 2005-03-30 : 05:13:22
Hi, Try this query Select distinct pid, testname, Max(dt) As Dt, Count(pid)from @Table Group By pid, testnamehaving count(pid) > 1order by pid, testname It will work