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

SELECT Column1, Column2, .... FROM Table1 Outer WHERE Column1 Operator (SELECT Column1, Column2 FROM Table2 WHERE Expr1 Outer - Expr2)

A correlated subquery is evaluated once for each row of the outer query. It allows you to compare values from the outer query to related data from the inner query. Correlated subqueries are useful when the inner query needs to return different results for each row being evaluated in the outer query, such as answering a question where the answer depends on the values in each row.

Uploaded by

Praty
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)
32 views1 page

SELECT Column1, Column2, .... FROM Table1 Outer WHERE Column1 Operator (SELECT Column1, Column2 FROM Table2 WHERE Expr1 Outer - Expr2)

A correlated subquery is evaluated once for each row of the outer query. It allows you to compare values from the outer query to related data from the inner query. Correlated subqueries are useful when the inner query needs to return different results for each row being evaluated in the outer query, such as answering a question where the answer depends on the values in each row.

Uploaded by

Praty
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 correlated subquery is evaluated once for each row processed by the parent statement.

The parent
statement can be a SELECT, UPDATE, or DELETE statement.
SELECT column1, column2, ....
FROM table1 outer
WHERE column1 operator
(SELECT column1, column2
FROM table2
WHERE expr1 =
outer.expr2);
A correlated subquery is one way of reading every row in a table and comparing values in each row
against related data. It is used whenever a subquery must return a different result or set of results for each
candidate row considered by the main query. In other words, you can use a correlated subquery to answer
a multipart question whose answer depends on the value in each row processed by the parent statement.
isplay the name of the empployee who earns highest salary.
----SQL>select ename from emp where sal=(select max(sal) from emp);

select* from humanresources.employee


----find out the employee who has more vacation hours than others
select nationalidnumber from HumanResources.Employee where VacationHours=(select
max(vacationhours) from HumanResources.Employee)

----find out the employees title who have minumum sickeleavehours


select businessentityid, jobtitle from HumanResources.employee where SickLeaveHours=(
select min(SickLeaveHours) from HumanResources.employee)

) ---Display the employee number and name for employee working as clerk and earning
highest salary among clerks.
----SQL>select empno,ename from emp where where job='CLERK'and sal=(select max(sal) from
emp where job='CLERK');

You might also like