Dotazy nad jednou tabulkou - možné řešení

From Wikivyuka
Jump to: navigation, search

Začneme zjištěním, jak vypadá tabulka Employees:

DESCRIBE employees;

Jak by mohly(či v některých případech měly) vypadat zapsané dotazy:

  1. SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME, SALARY FROM employees;
  2. SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME, SALARY, SALARY + 500 FROM employees;
  3. SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME, SALARY*12 FROM employees; SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME, (SALARY*12)+500 FROM employees;
  4. SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME, SALARY*12, (SALARY+500)*12 FROM employees;
  5. SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME, COMMISSION_PCT, DEPARTMENT_ID, JOB_ID FROM employees; SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME, COMMISSION_PCT, DEPARTMENT_ID, JOB_ID FROM employees WHERE DEPARTMENT_ID=80;
  6. SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME, 12*(SALARY*COMMISSION_PCT), JOB_ID FROM employees WHERE DEPARTMENT_ID=80;
  7. SELECT LAST_NAME ||' : Mesicni plat = '|| SALARY Mesicne FROM employees;
  8. SELECT FIRST_NAME, LAST_NAME, DEPARTMENT_ID, JOB_ID FROM employees WHERE LAST_NAME = 'Atkinson' ;
  9. SELECT FIRST_NAME, LAST_NAME, DEPARTMENT_ID, JOB_ID FROM employees WHERE LAST_NAME LIKE 'G%' ;
  10. SELECT LAST_NAME AS "Zamestnanci končící na 's' " FROM employees WHERE last_name LIKE '%s' ;
  11. SELECT FIRST_NAME, LAST_NAME, DEPARTMENT_ID, JOB_ID, SALARY FROM employees WHERE SALARY <=5000; SELECT FIRST_NAME, LAST_NAME, DEPARTMENT_ID, JOB_ID, SALARY FROM employees WHERE SALARY <=5000 ORDER BY SALARY;
  12. SELECT FIRST_NAME, LAST_NAME, DEPARTMENT_ID, JOB_ID, HIRE_DATE FROM employees WHERE HIRE_DATE >= '01-JAN-99';
  13. SELECT FIRST_NAME, LAST_NAME, DEPARTMENT_ID, JOB_ID, HIRE_DATE FROM employees WHERE HIRE_DATE like '%99';
  14. SELECT DEPARTMENT_NAME, MANAGER_ID FROM departments; SELECT DEPARTMENT_NAME || ' ma vedouciho: ' || MANAGER_ID AS "Oddeleni a vedouci" FROM departments;
  15. SELECT FIRST_NAME, LAST_NAME, DEPARTMENT_ID, JOB_ID FROM employees WHERE DEPARTMENT_ID=80;
  16. SELECT FIRST_NAME, LAST_NAME, DEPARTMENT_ID, JOB_ID FROM employees WHERE MANAGER_ID=146; SELECT FIRST_NAME, LAST_NAME, DEPARTMENT_ID, JOB_ID FROM employees WHERE MANAGER_ID=:mannum; (V otevřeném okně odkliknout NULL a dopsat požadovanou hodnotu.)
  17. SELECT FIRST_NAME, LAST_NAME, SALARY, JOB_ID FROM employees WHERE DEPARTMENT_ID=80 AND MANAGER_ID=:mannum AND SALARY > 7000;


Stránka Opakování SQL

Hlavní stránka předmětu