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 a dbms wizard?

0 Answers  


Explain the working of sql privileges?

0 Answers  


Can foreign key be deleted?

0 Answers  


What is the stuff and how does it differ from the replace function?

0 Answers  


What is a result set object returned by mssql_query()?

0 Answers  






What is the preferred way to create a clustered and non-clustered index? Which index should you create first the clustered or non-clustered?

0 Answers  


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

0 Answers  


What is the diff between Dynamic queries and static queries

1 Answers   CGG, ICS Integrated Computer Solutions,


What is the Query of getting last 10 transaction Reports (like insert, update, Delete Data from Tabele) ?

4 Answers   Wipro,


explain databases and sql server databases architecture? : Sql server database administration

0 Answers  


What is the syntax to execute the sys.dm_db_missing_index_details?

0 Answers  


From where can you change the default port?

3 Answers  


Categories