SQL Puzzle – Unsolved CASE Expression

This Unsolved CASE puzzle asks you to predict its result before execution. The preceding bitwise challenge drew more than 125 responses.

Unmatched guide channels are inspected beside an empty receiving recess.

SELECT CASE WHEN 1 <> 1 THEN 1 WHEN 2 <> 2 THEN 2 END AS Result;

Explain what happens when neither WHEN condition matches and no ELSE appears. Study the query before checking its output. A controlled execution can test your reasoning afterward.

Leave your result and explanation in the comments. The challenge remains open without a spoiler. The earlier puzzle and short-video resources provide context.

Related reading

A predicted expression result is not a tested explanation, it is reasoning to compare with the stated input and rules.

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.


Discover more from SQL Authority with Pinal Dave

Subscribe to get the latest posts sent to your email.

SQL CASE, SQL Scripts, SQL Server
Previous Post
SQL Puzzle – SELECT ~ 1 : Guess the Answer
Next Post
SQL SERVER – The Two Doors, Two Guards Puzzle

Related Posts

12 Comments. Leave new

  • Ok I guessed the answer correctly. If 1 does not = 1 then 1 / if 2 does not = 2 then 2. Both are false statements and there is no Else statement therefore no value so null is returned in the column named “Result”

    Reply
  • NULL because case conditions can’t evaluate to true

    Reply
  • Ketki Kulkarni
    May 20, 2021 3:36 pm

    NULL

    Reply
  • Mahesh Mahajan
    June 4, 2021 2:32 pm

    NULL as CASE Conditions are not returning TRUE

    Reply
  • Priti Kumari
    June 16, 2021 9:55 pm

    Null because none of the statements are true

    Reply
  • SANDYA RANI GATTUPALLI
    April 1, 2022 12:22 pm

    NULL as because none of the conditions are true

    Reply
  • Rhythm Luthra
    June 29, 2022 7:11 pm

    The following query will create a column and will display the column name as result if the when statement is true which is if 1 is not equal to 1 and 2 is also not equal to 2 in second statement only then in the result column first row will display as 1 and second row will display as 2.

    Reply
  • null because the query wasn’t close using the ;

    Reply
  • It wouldn’t run because there is no column from where the case statement would work on.
    There’s no column indicated after the Case statement or when given the condition.

    Reply
  • NULL

    Reply
  • bsenthilbaluSen
    April 19, 2023 12:04 am

    FROM keyword not found where expected

    Reply
  • Christopher Larkin
    July 14, 2023 7:01 pm

    The output of the SELECT statement you provided would be NULL.

    In this case, the first WHEN condition 1 1 evaluates to False because 1 is equal to 1. Therefore, the corresponding THEN expression is not executed. The second WHEN condition 2 2 also evaluates to False because 2 is equal to 2. As there is no ELSE clause specified, and neither of the WHEN conditions is true, the result would be NULL.

    The output column is labeled as ‘Result’ in the SELECT statement, but since no value is assigned to it, the result would be NULL for all rows returned.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.