[SOLVED] Get percentage calculation and update the column

Issue

I want to update two columns UG_length and AR_length as 80% and 20% respectively of NE_length from below query.

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 [email protected]_LINK_NE_VIEWER;

What is the easiest way of doing it in Oracle?

I need the percentage wise bifurcation of the NE_length column.

Solution

You can use update

update [email protected]_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) 
  

Answered By – ScaisEdge

Answer Checked By – Timothy Miller (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *