Viewing 3 posts - 1 through 3 (of 3 total)
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 =...
April 21, 2016 at 7:34 am
if you are working with SQL Server 2016 then there is a new function called STRING_SPLIT ( string , separator )
April 21, 2016 at 6:34 am
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...
April 21, 2016 at 4:48 am
Viewing 3 posts - 1 through 3 (of 3 total)