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,870
  • 5
  • 26
  • 52
Roto
  • 527
  • 2
  • 4
  • 16

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,870
  • 5
  • 26
  • 52