• Test your code before posting it!

    try:

    CREATE TABLE #Test

    (

    EmployeeID Int,

    LogTime DateTime

    )

    INSERT INTO #Test

    select 1001, '01/01/2010 10:22:36'

    union select 1002, '01/01/2010 10:24:37'

    union select 1003, '01/01/2010 10:24:38'

    union select 1001, '01/01/2010 10:24:39'

    union select 1001, '01/01/2010 10:24:40'

    union select 1002, '01/01/2010 10:24:45'

    union select 1003, '01/01/2010 10:26:45'

    --drop table #qupd

    select EmployeeID, LogTime, cast(Null as datetime) as PrevLogTime, cast(null as int) as TimeDiff

    into #qupd

    from #Test

    create clustered index cix_qupd on #qupd(EmployeeID, LogTime)

    declare @PrevLogTime datetime

    declare @TimeDiff int

    declare @EmployeeId int

    update #qupd set

    @PrevLogTime = PrevLogTime = CASE WHEN (EmployeeID = @EmployeeId) THEN @PrevLogTime ELSE NULL END

    ,@TimeDiff = TimeDiff = DATEDIFF(minute, @PrevLogTime, LogTime)

    ,@EmployeeId = EmployeeID

    ,@PrevLogTime = LogTime

    option (maxdop 1)

    select EmployeeID, LogTime

    from #qupd

    where PrevLogTime is null or TimeDiff > 1

    Please note: you have entries in your sample data for EmployeeID 1001 whcih are more than 1 minute appart, so you should expect them to be shown in results.

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]