dsm42026 2019-01-04 07:44
浏览 76

如何在员工维度(SCD Type2)表MySQL中创建唯一的employee_id

i'm creating a employee dimension table. I need to generate unique employee id when new employee is created. but when I update the existing employee details, the emp_id should be retained but the previous records active_ind should be set to 'N' and insert the updated record (SCD Type2). each insert should have a emp_key which can be a Auto_Increment.

I expect output as below

emp_key | emp_id    | emp_name  | emp_DOB   | Dept_id   | create_dt | update_dt | curr_row_ind
1   | 101   | Robert    | 5/12/1987 | dept~01   | 2/12/2018 | 4/10/2018 | N
2   | 102   | Albert    | 6/12/1988 | dept~01   | 3/11/2018 | NULL  | Y
3   | 101   | Robert    | 5/12/1987 | dept~02   | 4/10/2018 | NULL  | Y
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 cad图纸,chx-3六轴码垛机器人
    • ¥15 移动摄像头专网需要解vlan
    • ¥20 access多表提取相同字段数据并合并
    • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
    • ¥20 Java-Oj-桌布的计算
    • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
    • ¥20 有人知道这种图怎么画吗?
    • ¥15 pyqt6如何引用qrc文件加载里面的的资源
    • ¥15 安卓JNI项目使用lua上的问题
    • ¥20 RL+GNN解决人员排班问题时梯度消失