Dotazy - agregované funkce - možné řešení

From Wikivyuka
Revision as of 08:33, 24 February 2015 by Dur30 (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
  1. SELECT COUNT(*) FROM employees;
  2. SELECT COUNT(*) FROM employees WHERE department_id=80;
  3. SELECT COUNT(*) FROM departments;
  4. SELECT COUNT(DISTINCT department_id) FROM employees;
  5. SELECT AVG(salary), MAX(salary), MIN(salary), SUM(salary) FROM EMPLOYEES e, DEPARTMENTS d WHERE e.department_id=d.department_id AND d.department_name = 'IT';
  6. SELECT AVG(salary), department_id FROM employees GROUP BY department_id;
  7. SELECT department_id, AVG(salary) FROM employees HAVING AVG(salary) > 7000 GROUP BY department_id;
  8. Pomocí vnořeného dotazu:
SELECT last_name, salary
FROM   employees
WHERE  salary =
              (SELECT max(salary)
               FROM   employees);


Stránka Opakování SQL

Hlavní stránka předmětu