| 主表 | 类型 2 历史版本 |
|---|---|
| 视图 | 当前值覆盖全部历史行 |
| 价值 | 同源双口径切换 |
当前值视图
当前值视图
CREATE VIEW v_dim_customer_cur AS
SELECT h.customer_sk, h.name AS hist_name, c.name AS cur_name, h.start_date, h.end_date
FROM dim_customer h
JOIN dim_customer c ON h.customer_id = c.customer_id AND c.is_current = 1;视图名与列名都要标注口径(hist/cur),防止分析师拿错列。