SQL Query Output | EXL interview question

Question

select case when null=null then ‘Amit’ else ‘Rahul’ end from dual

in progress 2
TheDataMonk 55 years 14 Answers 2063 views Grand Master 1

Answers ( 14 )

  1. In SQL, Result of null=null is unknown and it can’t be true because two null values can never be same.
    So Answer will be:
    Rahul

  2. No 2 nulls are ever the same. Thus the condition “null=null” will never be met.
    Output: Rahul

  3. The Null value has a memory reference.2 Null values cannot have same memory
    reference.
    so output will be ‘Rahul’.

  4. Null=Null, condition will never satisfy. The output will always ‘Rahul’

  5. Sorry it a private answer.

  6. We cannot match NULL values. To the given question the output is RAHUL

  7. Rahul is the output

    As NULL=NULL, this condition will never satisfy

  8. Output: Rahul
    Reason: null=null condition will never hold true.

  9. This question is basically asking ‘Does one unknown equal another unknown?’ (NULL = NULL)
    That question is something no one can answer so it defaults to true or unknown depending on your ansi_nulls setting. if you have ANSI_NULLS off, this will evaluate to true otherwise it will be unknown.

    The answer is Rahul based on the assumption that ANSI_NULLS is ON.

    https://docs.microsoft.com/en-us/sql/t-sql/statements/set-ansi-nulls-transact-sql?redirectedfrom=MSDN&view=sql-server-ver15

  10. The null has a memory reference. So, one null value cannot be equal to another null value.

    See the below result:

    select
    case when null=null
    then ‘Amit’
    else ‘Rahul’
    end
    as Result
    from dual;
    ================================================

    Result=Rahul

  11. Output =Rahul
    As null =null can’t be true

  12. x = x only holds true when x is a known value. NULL is a textual representation of an unknown value. Two unknown values can’t conclusively state anything about their equality.

    Therefore, NULL = NULL results in either “Fasle” or “NULL”.
    So, the answer is Rahul.

  13. NULL = NULL condition can’t hold true.
    So, the answer is returned by the else clause.
    Hence, answer is ‘Rahul’.

  14. Two null values can never be the same therefore the output will be Rahul.

Leave an answer

Browse
Browse