Ver originalSELECT *FROM (SELECT * , MIN(LogTime) OVER(Partition BY UserID) MinTime FROM #TEMP) TWHERE LogTime=MinTime OR DateDiff(SECOND,MinTime,LogTime)>2;