0% found this document useful (0 votes)
60 views1 page

SQL Notes Part13

A subquery is a select query contained within another select query, consisting of an inner query and an outer query. There are two types of subqueries: nested subqueries, where the outer query depends on the inner query's result, and correlated subqueries, where the inner query relies on the outer query's result. The document provides examples of both types of subqueries, demonstrating how to find the maximum salary in an employee table.

Uploaded by

Rang Goud
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views1 page

SQL Notes Part13

A subquery is a select query contained within another select query, consisting of an inner query and an outer query. There are two types of subqueries: nested subqueries, where the outer query depends on the inner query's result, and correlated subqueries, where the inner query relies on the outer query's result. The document provides examples of both types of subqueries, demonstrating how to find the maximum salary in an employee table.

Uploaded by

Rang Goud
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

a) A select query contains another select query is called sub Query.

In this , two queries involved one


is inner query and second one is outer query.

in sub query first inner query will be executed than outer query executed. sub query is devided into
two types.

Syntax: select * from <tablename> where (condition) (select * from <tablename> where
(condition))

51)Nested subquery

52) co-related subquery

1)Nested subquery: Nested subquery is nothing but outer query depends on resulted inner query is
called nested subquery.

----->How to find the max salary in emp table?

a) select * from emp where salary=(select max(salary) from emp )

----->How to find the max salary in emp table?

a) select * from emp where salary=(select max(salary) from emp where salary<(select
max(salary)from emp where salary<(select max(salary) from emp ))).

12) co-related subquery: co-related sub query means inner query depends on outer query result.

co-related sub query first outer query will be executed than inner query will be execute.

You might also like