Prepare for your Next Interview
This is a discussion on SubQuery within the SQL Server forums, part of the Databases category; How is subquery used in sqlserver?I mean the command used for subquery?...
|
|||
|
Re: SubQuery
Hi Chitra,
A subquery is a select statement that is embedded in a clause of another select statement. A subquery is a SELECT query that returns a single value and is nested inside a SELECT, INSERT, UPDATE, or DELETE statement, or inside another subquery. Here is a simple subquery example where the employee details of maximum salary holder is retrieved, Code:
SELECT ename, empno, sal from Northwind.emp_new a where sal = (SELECT MAX(sal) FROM Northwind.emp_new b)
__________________
*** Innila *** |
|
|||
|
Re: SubQuery
A correction,
It is not true that A subquery is a SELECT query that returns a single value. Subquery can also return set of values... Here is an example, SELECT ename, empno, sal from Northwind.emp_new a where sal in (SELECT MAX(sal) FROM Northwind.emp_new b group by dept)
__________________
Cheers, :) James:) |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Join Query without using NOT IN subquery | Geek_Guest | SQL | 1 | 03-07-2007 04:24 PM |