1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| select csg_uuid from dwd.fct_tms_csg_df where csg_no = '26E004345'
select demd_uuid,csg_sub_uuid,csg_uuid,crr_head_uuid,stl_dlvr_uuid from dwd.fct_tms_order_rela_df_add where 1=1 and csg_uuid = '8c393f2db841449cbd72e60c67239469' group by demd_uuid,csg_sub_uuid,csg_uuid,crr_head_uuid,stl_dlvr_uuid
with cte_adj as ( select t1.stl_dlvr_uuid, t1.csg_no, t1.csg_uuid, t1.csg_status, t2.stl_dlvr_cost_uuid, case t1.cost_type when '6' then t1.adj_amt else 0 end as fangk_fee , case t1.cost_type when '39' then t1.adj_amt else 0 end as jud_fee from ads.ads_tms_cost_adj_di t1 left join dwd.fct_tms_stl_dlvr_cost_di t2 on t1.stl_dlvr_uuid = t2.stl_dlvr_uuid and t1.cost_type = t2.cost_type where t1.cost_type in ('39','6') and t1.csg_status in ('80','0') and t1.task_status = '20' ) ,cte_yzf_yjs as ( select t2.demd_uuid,t2.csg_sub_uuid,t2.csg_uuid,t2.crr_head_uuid,t2.stl_dlvr_uuid,t1.stl_dlvr_cost_uuid,t1.csg_status,t1.fangk_fee,t1.jud_fee from cte_adj t1 left join dwd.fct_tms_order_rela_df_add t2 on t1.csg_uuid = t2.csg_uuid and t1.stl_dlvr_uuid = t2.stl_dlvr_uuid ) select a.stl_dlvr_uuid,b.tax_includ_amt,b.cost_type,c.csg_status ,case when (c.csg_status != '0' or c.csg_status is null) and b.cost_type = '7' then b.tax_includ_amt else 0 end from dwd.fct_tms_stl_dlvr_di a join dwd.fct_tms_stl_dlvr_cost_di b on a.stl_dlvr_uuid = b.stl_dlvr_uuid and b.delete_flag = '0' and b.cost_type not in ('37','1') left join cte_yzf_yjs c on b.stl_dlvr_uuid = c.stl_dlvr_uuid and b.stl_dlvr_cost_uuid = c.stl_dlvr_cost_uuid WHERE a.is_valid = '1' and a.stl_dlvr_uuid = 'a3e70be3205c48f1935a4bb54b3577f8'
|