Home > database > SQL, decode, what is the difference between case the when? Their usage?
SQL, decode, what is the difference between case the when? Their usage?
Time:09-17
What is the difference between decode, case the when? Their usage?
CodePudding user response:
Case the when is stronger than the decode function, wait until you meet decode not achieve the function of the, you thought about the case when,
CodePudding user response:
Decode is equivalent to compare, use simple grammar, don't write too long,
Is the case when there are two ways, but a bit more complicated syntax, - conditions are very flexible Case 1 then the when condition value 1 2 then the when condition value 2 The else value 3 End
- equivalent to decode Case value When value 1 then 11 When value 2 then 22 The else value 33 end
CodePudding user response:
1. Handling of null different 2. To decode knock the word less
CodePudding user response:
Case the when are more powerful than decode, suitable for many conditions, and conditions for more complex situation, If the condition is simpler decode, can make the code more concise,
CodePudding user response:
Scope of a specific value compare with decode, compared with the case the when
CodePudding user response:
Added: the way the when case value, the decode (null, null, 1) can return 1, but the case of null when null then end cannot return 1