dangerous .. date ko row wise calculation .. dami researh .. lead ra lag herr

 select pb.CheckDate as Date,e.EmployeeGUID as emp,e.FirstName fname,e.LastName lname into #temp5 from paymentCheck pc

inner join PaymentBatch pb on pb.PaymentBatchGUID=pc.PaymentBatchGUID

inner join Employee e on e.EmployeeGUID=pc.PayeeGUID order by PayeeGUID 

with cte as(

select Date,emp,fname,lname,abs(DATEDIFF(DAY,Date,lead(Date) over (Partition by emp order by emp))) as checkgap from #temp5 )

select * from cte where checkgap=60

Comments