Untitled
SELECT DISTINCT dml_vsl_port_skd_his_act.VVD_CD AS VVD_CD, dml_vsl_port_skd_his_act.VSL_SLAN_CD AS Service_lane_code, dml_vsl_port_skd_his_act.VPS_PORT_CD AS Port_code, dml_vsl_port_skd_his_act.bfr_act_arr_dt as before_update_ATA, dml_vsl_port_skd_his_act.bfr_act_brth_dt as before_update_ATB, dml_vsl_port_skd_his_act.bfr_act_dep_dt as before_update_ATD, dml_vsl_port_skd_his_act.ACT_ARR_DT as after_update_ATA, dml_vsl_port_skd_his_act.ACT_BRTH_DT as after_update_ATB, dml_vsl_port_skd_his_act.ACT_DEP_DT as after_update_ATD, COUNT(DISTINCT (TIMESTAMP(dml_vsl_port_skd_his_act.ACT_ARR_DT ))) over (partition by dml_vsl_port_skd_his_act.VVD_CD, dml_vsl_port_skd_his_act.VSL_SLAN_CD, dml_vsl_port_skd_his_act.VPS_PORT_CD ) AS count_atb, COUNT(DISTINCT (TIMESTAMP(dml_vsl_port_skd_his_act.ACT_BRTH_DT ))) over (partition by dml_vsl_port_skd_his_act.VVD_CD, dml_vsl_port_skd_his_act.VSL_SLAN_CD, dml_vsl_port_skd_his_act.VPS_PORT_CD ) AS count_ata, COUNT(DISTINCT (TIMESTAMP(dml_vsl_port_skd_his_act.ACT_DEP_DT ))) over (partition by dml_vsl_port_skd_his_act.VVD_CD, dml_vsl_port_skd_his_act.VSL_SLAN_CD, dml_vsl_port_skd_his_act.VPS_PORT_CD ) AS count_atd, FROM `one-global-dde-prod.DWH.DML_VSL_PORT_SKD_HIS_ACT` AS dml_vsl_port_skd_his_act LEFT JOIN `DM_VIEWS.DMC_VSL_CNTR_V` AS dmc_vsl_cntr_vash_vvd ON dml_vsl_port_skd_his_act.VSL_CD = dmc_vsl_cntr_vash_vvd.VSL_CD QUALIFY count_ata > 1 or count_atb > 1 or count_atd > 1 ORDER BY 1, 2 LIMIT 500
Leave a Comment