Wednesday, May 26, 2010

T-SQL Puzzle 1: WHERE & GROUP BY

What will be the output of query given below. There is no FROM clause and no GROUP BY clause.

Does it throw an error?
Do you get any resultset?
Do you get a single row containing NULL?
Do you get a single row with 'Something' data?
Do you get multiple rows?
Cheers!


SELECT 'Something'
WHERE 1=2
HAVING 1=1

Note: You can easily check your answer by running the query but please check your skills before you do so. 

3 comments:

  1. AS My answer is it return NUll Record because where condition is 1=2 if it is 1=1 then it will display data


    but after excuting query i got result as 'Something' why give me the reason

    ReplyDelete
  2. This is horrible "puzzle". It in no way tests someone's SQL skills.

    ReplyDelete
  3. @Anonymous:
    If this is horrible "puzzle" then you should know the answer better... If someone can't answer this puzzle means there is something special in this ;)

    ReplyDelete

Here are few FREE resources you may find helpful.