Hi @Polachan Paily ,
Welcome to Microsoft Q&A!
Please refer below and check whether it is working.
If not, please provide more details about the rule and expected output.
SELECT EmpCode, min(attdate) MIN
,case when count(AttDate)=1 then NULL else max(AttDate) end MAX
FROM #EmpTime
group by EmpCode
order by EmpCode
Output:
EmpCode MIN MAX
01 2020-05-30 08:06:58.000 2020-05-30 18:06:58.000
02 2020-05-30 08:06:58.000 2020-05-30 20:10:58.000
03 2020-05-30 10:11:53.000 2020-05-30 18:11:53.000
04 2020-05-30 08:17:23.000 NULL
Best regards
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.