Vnořené dotazy - možné řešení
From Wikivyuka
SELECT last_name, salary FROM employees WHERE salary > (SELECT salary FROM employees WHERE last_name = 'Gates');
SELECT MAX(AVG(salary)) FROM employees GROUP BY job_id; . SELECT e.job_id, j.job_title, AVG(salary) FROM employees e, jobs j WHERE e.job_id = j.job_id GROUP BY e.job_id, j.job_title HAVING AVG(salary) = (SELECT MAX(AVG(salary)) FROM employees GROUP BY job_id);
SELECT e.job_id, j.job_title, AVG(salary) FROM employees e, jobs j WHERE e.job_id = j.job_id GROUP BY e.job_id, j.job_title HAVING AVG(salary) = (SELECT MIN(AVG(salary)) FROM employees GROUP BY job_id);
SELECT e.employee_id, e.last_name, e.salary, d.department_name FROM employees e, departments d WHERE e.department_id = d.department_id AND e.salary in (SELECT MIN(salary) FROM employees GROUP BY department_id);
SELECT employee_id, last_name, job_id, salary-(SELECT AVG(salary) FROM employees) viceNezPrumer FROM employees WHERE salary > (SELECT AVG(salary) FROM employees);