The function decode function that comes with oracle

1. The syntax of the decode function
     DECODE(value, if1, then1, if2,then2, if3,then3, . . . else )
   Value represents any column of any type in a table or any result of a calculation. When each value is tested, if the value of value is if1, the result of the Decode function is then1; if the value is equal to if2, the result of the Decode function is then2; and so on. In fact, multiple if/then pairs can be given. The Decode result returns else if the value result is not equal to any of the given pairs.
It should be noted that if, then and else can all be functions or calculation expressions.

     2. Example of use of the decode function

    1. decode(EPARCHY_CODE, --field name
              '0543',
              'Binzhou City',
              '0534',
              'Dezhou City',
              '0546',
              'Dongying City',
              '0530',
              'Heze City',
              '0531',
              'Jinan City',
              '0537',
              'Jining City',
              '0634',
              'Laiwu City',
              '0635',
              'Liaocheng City',
              '0539',
              'Linyi City',
              '0532',
              'Qingdao City',
              '0533',
              'Zibo City',
              '0535',
              'Yantai City',
              '0536',
              'Weifang',
              '0538',
              'Taian',
              '0631',
              'Weihai',
              '0632',
              'Zaozhuang',
              '0633',

              'Rizhao City') EPARCHY_CODE --- alias

           from sdcity ---- show

   2.DECODE(VALUE,'0','1','2')

1 if value is 0, 2 otherwise

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325723814&siteId=291194637