Tags
A puzzle, A quick query puzzle, A SQL Puzzle, A SQL Server Puzzle, Complex SQL Challenges, complex sql statement(puzzle), Complex TSQL Challenge, Interesting Interview Questions, Interview Qs.SQL SERVER Questions, Interview questions on Joins, Interview Questions on SQL, InterviewQuestions, InterviewQuestions for SQL, Join SQL Server tables where columns include NULL values, Joins, Joins Interview questions, Joins Puzzle, Khowal, Learn complex SQL, Learn SQL, Learn T-SQL, NULLs and JOINs, Objective Puzzle, Pawan, Pawan Khowal, Pawan Kumar, Pawan Kumar Khowal, PL/SQL Challenges, puzzle sql developer, Puzzles, Puzzles in SQL, PUzzles in SQL SERVER, Queries for SQL Interview, SELECT, SELECT Puzzle, SELECT SUM returns a row when there are no records, Some useful SQL puzzles to teach SQL, SQL, SQL 2012, SQL 2014, SQL 2014 Interview Questions, SQL Challenge, SQL Challenges, SQL Interview Questions, SQL Joins, SQL pl/sql puzzles, SQL puzzle, SQL Puzzles, SQL Queries, SQL QUERY PUZZLES, SQL Quiz, SQL Server - Best way to Handle NULLS in Joins, SQL Server Database, SQL SERVER Interview questions, SQL Server Puzzle, SQL SERVER Puzzles, SQL Server: joining NULL values, SQL Skills, SQL Sudoku, SQL Top clause, SQL Tricky Puzzles, SQL Trikcy question, sql/database interview for puzzle sql developer, SQLSERVER, T SQL Puzzles, T-SQL Challenge, The Biggest Gap Puzzle, The Gap Puzzle, The GroupBy Puzzle, Tough SQL Challenges, Tough SQL Puzzles, Tricky Puzzles in SQL, tricky puzzles in SQL Server, Tricky Questions, TSQL, TSQL Challenge, TSQL Challenges, TSQL Interview questions, TSQL Puzzles, TSQL Queries, TSQLPuzzles, Week puzzle
T-SQL Output Query | [ The JOIN Puzzle – Part 4 ( Join with an Empty Set ) ]
–Let’s say we have 2 table TestJoins5 and TestJoins6. Both the tables having only one ID column. Here you have to provide the output of the queries given below. Before that please go through the input data below.
Update – Added Outputs below – 17 Sep 2015
-- CREATE TABLE TestJoins5 ( ID INT ) GO INSERT INTO TestJoins5 VALUES (NULL),(NULL) GO CREATE TABLE TestJoins6 ( ID INT ) GO --Query 1 SELECT t1.ID , t2.ID FROM [dbo].[TestJoins5] t1 INNER JOIN [dbo].[TestJoins6] t2 ON t1.ID = t2.ID --Query 2 SELECT t1.ID , t2.ID FROM [dbo].[TestJoins5] t1 LEFT OUTER JOIN [dbo].[TestJoins6] t2 ON t1.ID = t2.ID --Query 3 SELECT t1.ID , t2.ID FROM [dbo].[TestJoins5] t1 RIGHT OUTER JOIN [dbo].[TestJoins6] t2 ON t1.ID = t2.ID --Query 4 SELECT t1.ID , t2.ID FROM [dbo].[TestJoins5] t1 FULL OUTER JOIN [dbo].[TestJoins6] t2 ON t1.ID = t2.ID --Query 5 SELECT t1.ID , t2.ID FROM [dbo].[TestJoins5] t1 CROSS JOIN [dbo].[TestJoins6] t2 -- |
Output of the above puzzles is given below-
Please leave a comment if you need solution to the above puzzle
Keep Learning
Hey Pawan, please do share the solutions of all puzzles you posted. Thanks!
LikeLike
Hi fkhan,
I have update the post with query outputs !
Pawan
LikeLike