What is Subquery in SQL Server?

 Posted by Raja on 7/12/2009 | Category: Sql Server Interview questions | Views: 19831

A subquery is a query that is nested inside a SELECT, INSERT, UPDATE, or DELETE statement, or inside another subquery. Subquery is an inner query or inner select, while the statement containing a subquery is also called an outer query or outer select.

For example

SELECT CustName, CustOrderDate, (SELECT DateTimeOrdered FROM OrderDetails as ODetails WHERE Ord.SalesOrderID = ODetails.SalesOrderID) AS OrderedDateTime FROM Orders AS Ord

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response