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)
            Asked
            
        
        
            Active
            
        
            Viewed 48 times
        
    1 Answers
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

