Vnořené dotazy - možné řešení

From Wikivyuka
Revision as of 05:42, 18 March 2014 by Dur30 (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
SELECT last_name, salary
FROM employees
WHERE salary >
              (SELECT salary
               FROM employees
               WHERE last_name = 'Gates');
SELECT MAX(AVG(salary)) FROM employees GROUP BY department_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);

Stránka Opakování SQL

Hlavní stránka předmětu