Guess what returns - Part1

Q: SELECT COUNT(*)

Click here to see answer


Ans: 1

Q: SELECT COUNT(*)+COUNT(*)

Click here to see answer


Ans: 2

Q: SELECT COUNT(5)

Click here to see answer


Ans: 1

Q: SELECT COUNT('5')

Click here to see answer


Ans: 1

Q: SELECT COUNT('')

Click here to see answer


Ans: 1

Q: SELECT COUNT()

Click here to see answer


Ans: Throws error

Q: SELECT 100

Click here to see answer


Ans: 100

Q: SELECT '100'

Click here to see answer


Ans: 100

Q: SELECT 100+100

Click here to see answer


Ans: 200

Q: SELECT '100'+100

Click here to see answer


Ans: 200

Q: SELECT '100'+100

Click here to see answer


Ans: 200

Q: Declare @a as int, @b as int
     SET @a=5,@b=2
      SELECT @a,@b

Click here to see answer


Ans: Throw error(Because SET @a=5,SET @b=2 is Valid)

Q: SELECT 5/2

Click here to see answer

Ans: 2

Q: SELECT CAST(5/2 as float)

Click here to see answer

Ans: 2

Q SELECT 5/2  Edit this query to get the result 2.5

Click here to see answer


Ans: SELECT CAST(5 as float)/CAST(2 As float)

Q: Declare @a,@b as int- Is this declaration Valid?

Click here to see answer


Ans: No (Because Declare @a,Declare @b as int is Valid)

Q: SELECT Cast((CAST(5 as float)/CAST(2 As float)) As int)

Click here to see answer


Ans: 2

Q: select a=1,b=2

Click here to see answer


Ans: a | b
      1 | 2

Q: SELECT a=1,b=2
     SELECT a

Click here to see answer


Ans: Error: Invalid column name 'a'.

Q: select a as 1

Click here to see answer


Ans: Incorrect syntax near the keyword 'select'

No comments:

Post a Comment