Writing SQL for Slowly Changing Dimensions: Type 1, Type 2, and Type 6 Merge Patterns Using Window Functions and CTEs | Wicked Smart Data