top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the difference between sub & correlated subquery?

+3 votes
374 views

What is the difference between sub & correlated subquery and In which case do we use each of them?

posted Apr 18, 2014 by Merry

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

A correlated subquery is a SELECT statement nested inside another T-SQL statement, which contains a reference to one or more columns in the outer query. Therefore, the correlated subquery can be said to be dependent on the outer query. This is the main difference between a correlated subquery and just a plain subquery.

A plain subquery is not dependent on the outer query, can be run independently of the outer query, and will return a result set. A correlated subquery, since it is dependent on the outer query will return a syntax errors if it is run by itself.

answer Apr 18, 2014 by Salil Agrawal
...