sql - Unexpected output when using a CASE statement -


When I stumbled on this scenario, I was trying to do some random things using the case statement. The first statement throws an error, but the other thing works fine how can someone help me to understand the execution of the statement. Select

  when 1 = 1 then 'Case 1' when 2 = 2 then select 2 or 10 when 1 = 1 then 1 when 2 = 2 then 'Case 2' or 10  

A case statement can not be withdrawn More than one single type when int and paranoid If there is a mixture of type, then type it has a high priority and therefore your case statement will have the option chosen for the return type. See for a list of data types preference.

If you try to return the second value ( 'case 2' ) then your second case statement will fail; For example: Select

  when 1 = 0 then 1 when 2 = 2 then 'Case 2' and 10'End  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -