0

I have a temp table named #t that will hold data that looks like shown below. How can I query to get the result desired I'm searching for the testId associated with the max(expirationDate) for each employee (empId)

enter image description here

Yogesh Sharma
  • 49,081
  • 5
  • 23
  • 49
Roto
  • 488
  • 2
  • 4
  • 14

1 Answers1

2

Use subquery :

select t.*
from #t t
where expirationdate = (select max(t1.expirationdate) 
                        from #t t1 
                        where t1.empid = t.empid
                       );
Yogesh Sharma
  • 49,081
  • 5
  • 23
  • 49