Answer Posted / rajkumar
As database developer, you must have ever written
subqueries in either SQL Server or any other database
platform. This article will describe shortly about types of
subquery.
A subquery is inner query that will be used by outer query.
A subquery could return scalar value or a series of value.
Based on query dependency, a subquery could be self-
contained or correlated one. A self-contained subquery is a
subquery independent from outer query, and correlated
subquery is a subquery that is referencing to a row in
outer query.
Self-contained subquery is easier to debug than correlated
subquery. And it is executed only once whereas correlated
subquery is executed once for each row of outer query.
Sample of self-contained subquery that returns scalar value
is shown below :
Select customerid
From dbo.orders
Where employeeid = (select employeeid from dbo.employees
where lastname = ‘RAJ’);
This query returns customers list whose employee is RAJ.
| Is This Answer Correct ? | 9 Yes | 1 No |
Post New Answer View All Answers
do views contain data ?
Where are full-text indexes stored?
Is it safe to delete log files?
What is the purpose of the model database?
How do I start sql server?
What are the steps to take to improve performance of a poor performing query? : sql server database administration
Mention the uses of stored procedures.
What are the rules to use the rowguidcol property to define a globally unique identifier column?
What is the difference between Clustered and Non-Clustered Index?
How will you make an attribute not process? : sql server analysis services, ssas
Describe triggers features and limitations?
What is correlated subquery in sql server?
What is cached report?
How to locate and take substrings with charindex() and substring() functions?
What is index fragmentation in ms sql server?