Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)

  • RE: get difference from previous record

    You could use the LAG() Windows Function which retrieves the value of the previous row. LEAD() retrieves the value on the next row. Something like;

    DECLARE @StartDate AS DATETIME

    SET @StartDate =...

  • RE: Adding single quotes in a string

    if you are working with SQL Server 2016 then there is a new function called STRING_SPLIT ( string , separator )

  • RE: Problems with dates

    I would probalby do it like this

    WITH CTE AS (

    SELECT E.EmployeeNumber, MAX(E.[Timestamp]) AS DateLastAdded

    FROM dbo.Employees AS E

    GROUP BY E.EmployeeNumber

    )

    SELECT Emp.EmployeeNumber, Emp.RagRating, Emp.[Timestamp],

    DATEDIFF(d, Emp.[Timestamp], GETDATE()) AS DateSinceAdded

    FROM...

Viewing 3 posts - 1 through 3 (of 3 total)