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

Magic Tables ?

2 Answers   Thomson Reuters,


What are cursors?

8 Answers  


Wht is SQL Injection Attack ?

3 Answers  


How to Run a Query on a Remote SQL Server?

2 Answers  


What is WITH CHECK OPTION

3 Answers   Karur Vysya Bank KVB,






What are the type of joins? When do we use Outer and Self joins?

3 Answers  


How can i change the column name.

12 Answers   Yardi Software, HCL,


system date format is "yy-mm-dd" "select getdate()" ----> 2009-01-24 20:03:28.513 if i write "select dateadd(dd,2,getdate()) ".it returns "2009-01-26 19:59:38.340"...my question is dat could it be possible to retrive da date in da format "26 jan 2009 ...."??

8 Answers  


Explain about analysis services?

0 Answers  


Does dbcc checkdb requires db to be in single_user mode? : sql server database administration

0 Answers  


in emptable i want to retrive the name of employee whose name in 'J'char.exp: arjun,jagadesh,niranjan,anju,aaaj etc.

8 Answers  


write an SQL query to list the employees who joined in the month of January?

0 Answers   Agilent, Amdocs,






Categories