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

What is the syntax to execute the sys.dm_db_missing_index_details?

0 Answers  


What is a self join in sql server?

0 Answers  


How to generate create view script on an existing view?

0 Answers  


How can we Use Linked Server? Uses of Linked server

1 Answers   IBM,


Can I save my report as html, excel or word? : sql server management studio

0 Answers  






what is maximum size of temp db?

4 Answers   iSoft,


Can sql servers link to other servers?

0 Answers  


what is meant by sql injection with example and one more question how to catch the errors in sqlserver

2 Answers  


What is an example of a primary key?

0 Answers  


Equi join and non equi join is possible with sql server?

0 Answers  


What is difference between after and before?

0 Answers  


What are Magic Table?

34 Answers   3i Infotech, Digiweb, Evalueserve, NIIT, PL,


Categories