sql - How to make a new column based on values in new and old table in Oracle -
sql - How to make a new column based on values in new and old table in Oracle -
given below construction of data
name    country s        republic of india d       ind c       afric r       africa f       ind v        republic of india    there many mistakes in country column. below table containing identified mistakes
    old value   new value   source  column ind  republic of india   avox    country afric   africa  avox    country    i need next table contains right value of country
name    country new_column s        republic of india    republic of india d       ind      republic of india c       afric   africa r       africa  africa f       ind      republic of india v        republic of india    republic of india    given below command using. snapsshot of data. info big
merge l03_a_avox_data_test n using (     select old_value , new_value       transformation_data_all column_identifier='country' , source_identifier='avox' ) o on (n.country = o.old_value) when matched   n.new_column = o.new_value;       
use decode function update  wrong column values. or,  create more explicit , readable,  utilize case construct.
using decode
decode(column, 'ind', 'india', 'afric', 'africa')    using case
case    when column = 'ind'       'india'    when column = 'afric'       'africa' end    so, update statement like,
update table_name    set country_name = <the decode or case  look explained above>  country_name in(country names list);        sql oracle 
 
  
Comments
Post a Comment