获取百分比计算并更新列

时间:2020-07-12 18:29:18

标签: mysql oracle percentage

我想从下面的查询中将两列UG_lengthAR_length分别更新为NE_length的80%和20%。

SELECT 
   CALCULATED_LENGTH AS NE_LENGTH , 
   (CASE WHEN RJ_CONSTRUCTION_METHODOLOGY NOT LIKE '%AERIAL%' OR RJ_CONSTRUCTION_METHODOLOGY IS NULL THEN NVL(CALCULATED_LENGTH,0) 
                  ELSE 0 END) AS UG_length,
    (CASE WHEN RJ_CONSTRUCTION_METHODOLOGY  LIKE '%AERIAL%' OR RJ_CONSTRUCTION_METHODOLOGY IS NULL THEN NVL(CALCULATED_LENGTH,0) 
                  ELSE 0 END) AS AR_length
   FROM NE.MV_SPAN@DB_LINK_NE_VIEWER;

请帮助在oracle中最简单的方法

我需要NE_length列的按比例分叉

1 个答案:

答案 0 :(得分:1)

您可以使用更新

update NE.MV_SPAN@DB_LINK_NE_VIEWER
   set UG_length  =  (CASE WHEN RJ_CONSTRUCTION_METHODOLOGY NOT LIKE '%AERIAL%' OR RJ_CONSTRUCTION_METHODOLOGY IS NULL THEN NVL(CALCULATED_LENGTH,0)*0.8
                  ELSE 0 END)
   , AR_length  = (CASE WHEN RJ_CONSTRUCTION_METHODOLOGY NOT LIKE '%AERIAL%' OR RJ_CONSTRUCTION_METHODOLOGY IS NULL THEN NVL(CALCULATED_LENGTH,0)*0.2
                  ELSE 0 END)