The document discusses different types of subqueries, including single-row subqueries that return a single value and multi-row subqueries that return multiple values. It provides examples of queries using >, <, IN, ALL, and ANY operators with multi-row subqueries to return rows where the column value is greater than, less than, included in, greater than all, less than all, greater than any, or less than any of the values in the subquery result.
The document discusses different types of subqueries, including single-row subqueries that return a single value and multi-row subqueries that return multiple values. It provides examples of queries using >, <, IN, ALL, and ANY operators with multi-row subqueries to return rows where the column value is greater than, less than, included in, greater than all, less than all, greater than any, or less than any of the values in the subquery result.
The document discusses different types of subqueries, including single-row subqueries that return a single value and multi-row subqueries that return multiple values. It provides examples of queries using >, <, IN, ALL, and ANY operators with multi-row subqueries to return rows where the column value is greater than, less than, included in, greater than all, less than all, greater than any, or less than any of the values in the subquery result.
avg(salary) from emp group by did); Eid Ename did salary jid 100 a 10 10000 j1 101 b 10 12000 j1 102 c 20 2000 j2 103 d 20 8000 j3 104 e 10 14000 j4 105 f 30 5000 j3
did avg(salary) 10 12000 20 5000 30 5000 Select * from emp where salary in (select avg(salary) from emp group by did); 105 f 30 5000 j3
Select * from emp where salary > all (select
avg(salary) from emp group by did); 104 e 10 14000 j4
Select * from emp where salary <all (select
avg(salary) from emp group by did); 102 c 20 2000 j2 Select * from emp where salary <any (select avg(salary) from emp group by did); Eid Ename did salary jid 100 a 10 10000 j1 102 c 20 2000 j2 103 d 20 8000 j3 105 f 30 5000 j3
Select * from emp where salary >any (select
avg(salary) from emp group by did); Eid Ename did salary jid 100 a 10 10000 j1 101 b 10 12000 j1 103 d 20 8000 j3 104 e 10 14000 j4
In the above query, subquery is returning
more than one value.These type of subquery is called as multirow subquery. We have to use multirow subquery operators. IN(multiple values can be compared at a time) ANY ALL >all--àgreater than the maximum <all---àless than the minimum >anyàgreater than the minimum <anyàless than the maximum