Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alcheng10/55ca7484e61f5665481e89e78fd69fbf to your computer and use it in GitHub Desktop.
Save alcheng10/55ca7484e61f5665481e89e78fd69fbf to your computer and use it in GitHub Desktop.
Date_Daily_Island_with_Rank_with_group
SELECT
  RegistrationGUID
  ,RegistrationNo
  ,PolicyNo
  ,MIN(FullDate) AS StartDate
  ,MAX(FullDate) AS EndDate
  ,Cover_YN
  ,COUNT(FullDate) AS NumberDaysCovered
FROM DimCustomer_Car_Status_by_day_with_rank
GROUP BY 
  RegistrationGUID
  ,Cover_YN
ORDER BY
  RegistrationNo ASC
  ,StartDate ASC
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment