Quantcast
Viewing latest article 23
Browse Latest Browse All 83

re: Debunking Kimball Effective Dates

Kyle Hale,

I am not sure why you are referring to get "next row's Start date" with Windowing function but to get the "next row's End date":

SELECT [Id]

,[NId]

,[Name]

,[HomeTown]

,[MaritalStatus]

,[NumberOfChildren]

,[SCDStartDate]

,COALESCE(LEAD([SCDStartDate]) OVER (PARTITION BY [NId],[Name],[HomeTown] ORDER BY [NId]), '99991231') "SCDEndDate"

,CASE WHEN LEAD([SCDStartDate]) OVER (PARTITION BY [NId],[Name],[HomeTown] ORDER BY [NId]) IS NULL THEN 1 ELSE 0 END "IsLatest"

FROM dbo.Customer C


Viewing latest article 23
Browse Latest Browse All 83

Trending Articles