adspace
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
Can we do dml on views?
How to convert character strings into numeric values?
What kind of problems occurs if we do not implement proper locking strategy?
Explain “row_number()” in sql server with an example?
What are the kinds of subquery?
How efficient you are in oracle and SQL server?
What are the pros and cons of putting a scalar function in a queries select list or in the where clause?
what is spatial nonclustered index
What is subquery? Explain the properties of a subquery?
What is sql or structured query language?
what is the difference between openrowset and openquery?
List out the different types of locks available in sql server?
How do I create a trace in sql server?
Why we use the openxml clause?
Is there any performance difference between if exists (select null from table) and if exists (select 1 from table)?