Can we rewrite subqueries into simple select statements or
with joins? Example?




Answers were Sorted based on User's Feedback



Can we rewrite subqueries into simple select statements or with joins? Example?..

Answer / divya kalra

Subqueries can often be re-written to use a standard outer
join, resulting in faster performance. As we may know, an
outer join uses the plus sign (+) operator to tell the
database to return all non-matching rows with NULL values.
Hence we combine the outer join with a NULL test in the
WHERE clause to reproduce the result set without using a
sub-query.

Is This Answer Correct ?    4 Yes 1 No

Can we rewrite subqueries into simple select statements or with joins? Example?..

Answer / syed sajjad

Yes we can write using Common Table Expression (CTE). A Common Table Expression (CTE) is an expression that can be thought of as a temporary result set which is defined within the execution of a single SQL statement. A CTE is similar to a derived table in that it is not stored as an object and lasts only for the duration of the query.

Is This Answer Correct ?    1 Yes 0 No

Post New Answer




More SQL Server Interview Questions

Can you explain the role of each service?

1 Answers  


How to change location of errorlog in SQL?

2 Answers   ABC, IBM,


What is excution Plan in sql server

1 Answers   TCS, CarrizalSoft Technologies,


what is the difference between Delete and Truncate

4 Answers   Geo Research Centre, CarrizalSoft Technologies,


Psudo colums

1 Answers   HP,






how to rest identity columns in sql server

3 Answers   Matrix,


What are the magic tables in SQL Server 2000?

7 Answers   Merrill Lynch, Infogain,


is it possible to use a variable in a query with the IN clause (a,b,c..z), without getting quotes or conversion errors?

2 Answers  


what is performance tunning in sql server ? explain.

1 Answers   Thomson Reuters,


Is index a datbase objects in sql server?

2 Answers  


Describe about first three Normal forms.

1 Answers   HP,


what is a cursor and what is its use?

2 Answers   L&T,






Categories