SELECT (interactive) Examples
1. Find all employees who make more than their managers. This example illustrates the use of correlation names.
select e.ename
from employee e, dept, employee m
where e.dept = dept.dno and dept.mgr = m.eno
and e.salary > m.salary;
2. Select all information for employees that have salaries above the average salary.
select * from employee
where salary > (select avg(salary) from employee);
3. Select employee information sorted by department and, within department, by name.
select e.ename, d.dname from employee e, dept d
where e.dept = d.dno
order by dname, ename;
4. Select lab samples analyzed by lab #12 from both production and archive tables.
select * from samples s
here s.lab = 12
union
select * from archived_samples s
where s.lab = 12
Last modified date: 01/30/2023