Join 3 tables (table1, table2 & table3) in a single query.
Inner join should be applied for table1 & table 2 and left
outer join for table1 & table3 where table2.dept is ABC
Answer Posted / sumit m.
Although the above answer is correct. I am preferring
paranthesis in the answer, something like below:
There are 2 forms of the query for the answer:
SELECT *
FROM (table t1 INNER JOIN table2 t2 ON t1.col = t2.col AND
t2.dept = 'ABC')
LEFT JOIN table t3 ON t1.col = t3.col
OR
SELECT *
FROM (table t1 INNER JOIN (SELECT * FROM table2 WHERE dept
= 'ABC') t2 ON t1.col = t2.col)
LEFT JOIN table t3 ON t1.col = t3.col
Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
What is the difference between composite index and covering index?
Why should we go for stored procedures? Why not direct queries?
How to defragment indexes with alter index ... Reorganize?
What are the advantages of using stored procedures in sql server?
Explain the use of containers in ssis?
How check triggers in sql server?
Define normalisation?
What is star, snowflake and star flake schema? : sql server analysis services, ssas
What is sleeping status in sql server?
Can you explain what is indexed view? How to create it?
What is the difference between a function and a stored procedure?
Describe different Processing Modes offered by SSRS?
how to create “alternate row colour”?
How to optimize stored procedures in sql server?
What is constraints and its types?