Itz Puzzle tym

Try to guess the Answers for the below Queries and also check with the key which i have provided. Click here to see the answers from the below.

—————————————————
— I – Silly SELECTs. But Funny results.
—————————————————
USE [AdventureWorks2008R2]
GO
—————————————————
SELECT *
FROM [Person].[Address]
WHERE 1=1
—————————————————
SELECT *
FROM [Person].[Address]
WHERE 1 IS 1
—————————————————
SELECT *
FROM [Person].[Address]
WHERE 1=0
—————————————————
SELECT *
FROM [Person].[Address]
WHERE AddressID = NULL
—————————————————
SELECT *
FROM [Person].[Address]
WHERE NULL = NULL
—————————————————
SELECT *
FROM [Person].[Address]
WHERE NULL IS NULL
—————————————————
SELECT *
FROM [Person].[Address]
WHERE NULL = 1
—————————————————
SELECT *
FROM [Person].[Address]
WHERE NULL IS 1
—————————————————
SELECT *
FROM [Person].[Address]
WHERE NULL IS ‘1’
—————————————————
SELECT *
FROM [Person].[Address]
WHERE [AddressLine1] LIKE ‘%[%]%’
—————————————————
SELECT *
FROM [Person].[Address]
WHERE [AddressLine1] LIKE ‘%%%’
—————————————————
SELECT *
FROM [Person].[Address]
WHERE [AddressID] LIKE ‘[^1-4]’
—————————————————
SELECT *
FROM [Person].[Address]
WHERE [AddressID] LIKE ‘[1-4]’
—————————————————
SELECT ‘SQLVersity’+1
—————————————————
SELECT (SELECT ‘SQLVersity’)
—————————————————
SELECT SELECT ‘SQLVersity’
—————————————————
SELECT * FROM ‘SQLVersity’
—————————————————
SELECT ‘SQLVersity’ FROM [DatabaseLog]
—————————————————

— II – NULL makes your life blank.
—————————————————
SELECT NULL + 1
—————————————————
SELECT ‘NULL’ + 1
—————————————————
SELECT ‘NULL’ + ‘1’
—————————————————
SELECT NULL + ‘1’
—————————————————
SELECT COALESCE(NULL,1)+1
—————————————————
SELECT NULL = NULL
—————————————————
SELECT NULL IS NULL
—————————————————
SELECT NULL = 1
—————————————————
SELECT 1=1
—————————————————
SELECT NULL + NULL
—————————————————
SELECT NULL – NULL
—————————————————
SELECT NULL * NULL
—————————————————
SELECT NULL \ NULL
—————————————————
SELECT NULL / NULL
—————————————————
SELECT NULL % NULL
—————————————————

— III – Speciality of Special characters
—————————————————
SELECT !
—————————————————
SELECT @
—————————————————
SELECT #
—————————————————
SELECT $
—————————————————
SELECT %
—————————————————
SELECT ^
—————————————————
SELECT &
—————————————————
SELECT *
—————————————————
SELECT (
—————————————————
SELECT )
—————————————————
SELECT
—————————————————
SELECT “”
—————————————————
SELECT ‘?’
—————————————————

— IV – TOP IS always at TOP
—————————————————
SELECT TOP 5.9 *
FROM [Person].[Address]

—————————————————
SELECT TOP ‘5’ *
FROM [Person].[Address]
—————————————————
SELECT TOP NULL *
FROM [Person].[Address]

—————————————————

— V – Conversion conflicts
—————————————————
SELECT 3+3
—————————————————
SELECT 5+‘SQLVersity’
—————————————————
SELECT 5+‘5’
—————————————————
SELECT ‘SQLVersity’+5
—————————————————
SELECT ‘SQLVersity’+‘3’
—————————————————

— VI – The Crazy COUNT
—————————————————
SELECT COUNT(6)
—————————————————
SELECT COUNT(*)
—————————————————
SELECT COUNT(0)
—————————————————
SELECT COUNT(‘6’)
—————————————————
SELECT COUNT(‘SQLVersity’)
—————————————————
SELECT COUNT(6+8)
—————————————————
SELECT COUNT(6+‘8’)
—————————————————
SELECT COUNT(SV)
—————————————————
SELECT COUNT(‘SQLVersity’)
—————————————————
SELECT TOP 5 COUNT(*)
FROM [Person].[Address]
—————————————————
SELECT DISTINCT TOP 5 COUNT(*)
FROM [Person].[Address]
—————————————————
SELECT COUNT(9)
FROM [Person].[Address]
—————————————————
SELECT COUNT(9+9)
FROM [Person].[Address]
—————————————————
SELECT COUNT(9+‘SQLVersity’)
FROM [Person].[Address]
—————————————————
SELECT COUNT(‘SQLVersity’)
FROM [Person].[Address]
—————————————————
SELECT COUNT(‘*’)
FROM [Person].[Address]
—————————————————
SELECT COUNT(‘$’)
FROM [Person].[Address]
—————————————————
SELECT COUNT(‘>’)
FROM [Person].[Address]
—————————————————
SELECT COUNT(SV)
FROM [Person].[Address]

—————————————————
SELECT COUNT(SELECT TOP 5 [AddressID]
FROM [Person].[Address])
—————————————————
SELECT COUNT(SELECT COUNT(*)
FROM [Person].[Address])
—————————————————
SELECT COUNT(*)
—————————————————
SELECT COUNT(4)
—————————————————
SELECT COUNT(*) + COUNT(*)
—————————————————

— VII – Aggressive Aggregates.
—————————————————
SELECT SUM(1-3*4)
SELECT AVG(1-3*4)
SELECT MAX(1-3*4)
SELECT MIN(1-3*4)
SELECT COUNT(1-3*4)
—————————————————
SELECT SUM(1,2,3)
SELECT AVG(1,2,3)
SELECT MAX(1,2,3)
SELECT MIN(1,2,3)
SELECT COUNT(1,2,3)
—————————————————
SELECT SUM(’55’)
SELECT AVG(’45’)
SELECT MAX(’34’)
SELECT MIN(’14’)
SELECT COUNT(’13’)
—————————————————
SELECT SUM(‘SQLVersity’)
SELECT AVG(‘SQLVersity’)
SELECT MAX(‘SQLVersity’)
SELECT MIN(‘SQLVersity’)
SELECT COUNT(‘SQLVersity’)
—————————————————
SELECT SUM(‘SQLVersity,SV’)
SELECT AVG(‘SQLVersity,SV’)
SELECT MAX(‘SQLVersity,SV’)
SELECT MIN(‘SQLVersity,SV’)
SELECT COUNT(‘SQLVersity,SV’)
—————————————————
SELECT SUM(sv)
SELECT AVG(sv)
SELECT MAX(sv)
SELECT MIN(sv)
SELECT COUNT(sv)
—————————————————
— VIII – Magical Microsoft functions
—————————————————
— ASCII
—————————————————
SELECT ASCII(‘14533’)
—————————————————
SELECT ASCII(14533)
—————————————————
SELECT ASCII()
—————————————————
SELECT ASCII(NULL)
—————————————————
SELECT ASCII(‘NULL’)
—————————————————
SELECT ASCII(0)
—————————————————
SELECT ASCII(‘94533’)
—————————————————
SELECT ASCII(‘X4533’)
—————————————————
SELECT ASCII(0.0)
—————————————————
SELECT ASCII(1.1)
—————————————————
SELECT ASCII(1.x)
—————————————————
SELECT ASCII(‘1.x’)
—————————————————
— Lovely Len.
—————————————————
SELECT LEN(‘ABC’)
—————————————————
SELECT LEN(-456.123)
—————————————————
SELECT LEN(-456.123 )
—————————————————
SELECT LEN(-456.123 0)
—————————————————
SELECT LEN(0 -456.123 )
—————————————————
SELECT LEN( -456.123 )
—————————————————
SELECT LEN( -456. 123 )
—————————————————
SELECT LEN( – 456.123 )
—————————————————
SELECT LEN( + – 456.123 )
—————————————————
SELECT LEN( + – 456.123 + )
—————————————————
— ROUND
—————————————————
SELECT ROUND(123.456)
—————————————————
SELECT ROUND(123.456,0)
—————————————————
SELECT ROUND(123.456,-2)
—————————————————
SELECT ROUND(123.456,-10)
—————————————————
SELECT ROUND(123.456,2)
—————————————————
SELECT ROUND(123.456,10)
—————————————————
SELECT ROUND(-123.456)
—————————————————
SELECT ROUND(-123.456,0)
—————————————————
SELECT ROUND(-123.456,-2)
—————————————————
SELECT ROUND(-123.456,-10)
—————————————————
SELECT ROUND(-123.456,2)
—————————————————
SELECT ROUND(-123.456,10)
—————————————————
SELECT ROUND(‘SV’,0)
—————————————————
SELECT ROUND(123.456,‘SV’)
—————————————————
— UPPER & LOWER
—————————————————
SELECT UPPER(‘abc’)
—————————————————
SELECT UPPER(abc)
—————————————————
SELECT UPPER(123)
—————————————————
SELECT UPPER(‘123’)
—————————————————
SELECT UPPER(‘abc123’)
—————————————————
SELECT UPPER(‘abc!@#’)
—————————————————
SELECT UPPER(‘!@#abc’)
—————————————————
— LTRIM & RTRIM
—————————————————
SELECT LTRIM(‘abc’)
—————————————————
SELECT LTRIM(‘abc         ‘)
—————————————————
SELECT LTRIM(‘O      abc      ‘)
—————————————————
SELECT LTRIM(123)
—————————————————
SELECT LTRIM( 123)
—————————————————
SELECT LTRIM(123 )
—————————————————
SELECT LTRIM(123 9)
—————————————————
SELECT LTRIM(0 123 9)
—————————————————
— CONCAT
—————————————————
SELECT CONCAT(‘SQL’,’Versity’)
—————————————————
SELECT CONCAT(123,‘Versity’)
—————————————————
SELECT CONCAT(-123,‘Versity’)
—————————————————
SELECT CONCAT(-123y,‘Versity’)
—————————————————
SELECT CONCAT(-1#&^W23,‘Versity’)
—————————————————
— LEFT & RIGHT
—————————————————
SELECT LEFT(‘SQLVersity’,3)
—————————————————
SELECT LEFT(‘SQLVersity’,0)
—————————————————
SELECT LEFT(‘SQLVersity’,-3)
—————————————————
SELECT LEFT(123456,3)
—————————————————
— SPACE
—————————————————
SELECT SPACE(7)
—————————————————
SELECT SPACE(-7)
—————————————————
SELECT SPACE(0)
—————————————————
SELECT SPACE(NULL)
—————————————————
SELECT SPACE(‘7’)
—————————————————
SELECT SPACE(‘SQL’)
—————————————————

Happy Reading & Happy New Year  :-)

Leave a Reply

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