sql - how to calulated length with respect to two column entries -
The code mentioned below can be made more compact, I like the length of cable for the same rack, equal to the same rack insulation Trying to do the length is 6 meters and then from one rack to the other rack up to 5 meters each rack rises and the rest are some random length. Database R has the following columns
ID RACK_A RACK_B LENGTH 1 RK 1 RK1 2 RK2 RK 1 RK 1 RK2 4 MCR Desk PCR 5 Car Izst 6 PCR Car < / Pre> and similarly about 2000 entries
update MASTER_SCHEDULE set CABLE_LENTH = switch (RACK_A = 'RK1' and RACK_B = 'RK1', 6, RACK_A = 'RK2 'And RACK_B =' RK2 ', 6, RACK_A =' RK3 'and RACK_B =' RK3 ', 6, racket_a =' rk4 'and' rakab = 'rk 4', 6, rca_a = 'rk5' and Rackage = 'RK5', 6, rack_a = 'rk 6' and rakaji = 'rk 6', 6, rap_a = 'r 7 'and' Rakyaji = 'RK7', 6 and so on LNGH = 6, RAP_A = 'RK1' and Rakaji = 'RK2' or 'RAP_A =' RK2 plus 20 statements 'and RACK_B =' RK 1 ', 6.5, RAP_A =' RK1 'and RACK_B =' RK3 'or RACK_A =' RK3 'and RACK_B =' RK1 ', 7, RACK_A =' RK1 'and RACK_B =' RK4 'or RACK_A = 'RK4' and RACK_B = 'RK1', 7.5, RACK_A = 'RK1' and RACK_B = 'RK5' or RACK_A = 'RK5' and RACK_B = 'RK1', 8, RACK_A = 'RK1 'And RACK_B =' RK6 'or RACK_A =' RK6 'and RACK_B =' RK1 ', 8.5, RACK_A =' RK1 'and RACK_B =' RK7 'or RACK_A =' RK7 'and RACK_B =' RK 1 ', 9o Therefore increase from each length + .5, RACK_A = 'MCR Desk' and RACK_B = 'PCR =' or RACK_A = 'PCR' and RACK_B = 'MCR_DESK', 54, RACK_A = 'car' and RACK_B = 'ingest' or RACK_A = 'ingest' and RACK_B = 'car', 47 and random figure on each length, true, 0) where id & gt; = 1 and id & lt; = 2000
With sample data here, I assumed the column RACK_A and RACK_B All data in the format is "RK {cell number}". Then you can try this query:
update MASTER_SCHEDULE set CABLE_LENTH = ABS ((rights (RACK_A, LEN (RACK_A) -3) - Right (RACK_B, LEN (RACK_B) - 3))) * 0.5 + 6 where id & gt; = 1 and id & lt; = 2000 For reference:
Comments
Post a Comment