-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathANYorALL.sql
More file actions
34 lines (23 loc) · 773 Bytes
/
ANYorALL.sql
File metadata and controls
34 lines (23 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
-- ALL or ANY example
select * from employees where region_id > ANY (select region_id from regions where country='United States')
select * from employees where region_id > ALL (select region_id from regions where country='United States')
---
select *
from employees
where department in (select department from departments where division ='Kids')
and hire_date > All (select hire_date
from employees
where department ='Maintenance')
--------------------------------------------
select salary, count(salary)
from employees
group by salary
having count(salary) >1
order by salary desc
------------------------------
select salary
from employees
group by salary
having count(*) >= All (select count(*) from employees group by salary)
order by salary desc
limit 1