Equivalent if statement
When the decode function compares 1 parameters
SELECT Id,decode (inparam, ' becomparedparam ', ' value 1 ', ' Value 2 ') name from bank
#如果第一个参数inParam = = ' Becomparedparam ', the name given by select is displayed as a value of 1,
#如果第一个参数inParam! = ' Becomparedparam ', then select gets the name displayed as a value of 2
When the decode function compares multiple parameters
SELECT Id,decode (inparam, ' para1 ', ' value 1 ', ' para2 ', ' Value 2 ', ' para3 ', ' Value 3 ', ' para4 ', ' Value 4 ', ' Para5 ', ' value 5 ') name from bank
#如果第一个参数inParam = = ' Para1 ' then the select Gets a value of 1 as shown;
#如果第一个参数inParam = = ' Para2 ' then the select Gets a value of 2 as shown;
#如果第一个参数inParam = = ' Para3 ' then the select Gets a value of 3 as shown;
#如果第一个参数inParam = = ' Para4 ' then the select Gets a value of 4 as shown;
#如果第一个参数inParam = = ' Para5 ' then the select Gets a value of 5 as shown;
#都不相等就为 '
SQL Decode (...) Use of functions