This article is half-done without your Comment! *** Please share your thoughts via Comment ***
This interview post is for Database Fresher Candidates.
Just check the below SQL Questions, you feel like this is very easy, and most of the DB Person already knew about it.
I asked this simple question in one of the recent interviews, and I can’t explain those shocking answers in this post.
I can tell you one thing is: In the database or SQL fundamentals, everything is a Table.
Create a table with sample data:
1 2 3 4 |
CREATE TABLE tbl_abc (id INT) GO INSERT INTO tbl_abc VALUES (1),(2) GO |
SQL 1: Which is the table?
Ans: tbl_abc
1 2 |
SELECT *FROM tbl_abc GO |
SQL 2: Which is the table?
Ans: T (derived table)
1 2 3 4 5 |
SELECT * FROM ( SELECT *FROM tbl_abc )AS T |
SQL 3: Which is the table?
Ans: T(a) (derived table)
1 2 3 4 |
SELECT * FROM ( VALUES(1),(2),(3) ) T(a) |
SQL 4: Which is the table?
Ans: T (derived table)
1 2 3 4 5 6 7 8 |
SELECT * FROM ( SELECT * FROM tbl_abc WHERE ID = 1 UNION ALL SELECT * FROM tbl_abc WHERE ID = 2 ) T (derived table) |
Leave a Reply