1. Standard SQL specification
1 One, single if2 1,3 4 ifA=... Then5 .........6 End if;7 8 2,9 Ten ifA=... Then One ...... A Else - .... - End if; the - two or more if - - ifA=.. Then + ...... -Elsif A=.. Then + .... A End if; atThe middle here is "elsif", not else.IF。 Special attention is needed here.
2. Decode function
syntax for decode :
DECODE (Value,if1,then1,if2,then2,if3,then3,...,else)
Indicates that if value equals IF1, the result of the Decode function returns THEN1,..., if it is not equal to any one if value, else is returned.
3. Case
Case whenA='1' Then 'xxxx' whenA='2' Then 'ssss'Else 'zzzzz'End as
Note the point:
1. Start with case and end with end
2. When the branch is followed by the condition, then the result is displayed
3, else in addition to the default, similar to the high-level language program switch case default, you can not add
4, END followed by alias
3 Ways to If/else in Oracle