Forum Replies Created

Viewing post 1 (of 1 total)

  • RE: help needed for sql query

    Will this work:

    SELECT A.Customer

    , A.[Status]

    , NumDays = SUM(DATEDIFF(d,A.LastUpdateDate , COALESCE(B.LastUpdateDate, GETDATE())))

    FROM #TempTable A

    OUTER APPLY (SELECT TOP 1 LastUpdateDate FROM #TempTable

    WHERE LastUpdateDate > A.LastUpdateDate

    AND A.Customer = Customer

    ORDER BY LastUpdateDate) B

    Group...

Viewing post 1 (of 1 total)