무회blog

DB: hr 사용 예제, group by, 내장함수(sum,avg,max,count) 본문

DB

DB: hr 사용 예제, group by, 내장함수(sum,avg,max,count)

최무회 2021. 2. 8. 00:45
--
--SELECT * FROM employees;
--
--select EMPLOYEE_ID, last_name from employees;
--
--SELECT job_id FROM employees;
--
---- DisTinct 중복된 데이터 제거
--SELECT DISTINCT job_id FROM employees;

--* NOT 연산자
SELECT department_id, DEPARTMENT_NAME
    FROM DEPARTMENTS
--    WHERE NOT department_id = 10;
where department_id <>10;


select * from EMPLOYEES;

--* IS Not null
SELECT employee_id, last_name, commission_pct
    FROM employees
  where COMMISSION_PCT is not null;
  
  
SELECT employee_id, last_name, hire_date
    FROM EMPLOYEES
  where hire_date BETWEEN '07/01/01'
    AND '07/12/31';
SELECT employee_id, last_name, hire_date
    FROM EMPLOYEES
    where hire_date LIKE '07%';
  
  --------------------------
  SELECT employee_id, last_name, hire_date
  from EMPLOYEES
  where last_name not Like '%a%';
  
  select * from EMPLOYEES;
  select sum(salary) from employees;
  select avg(salary) from employees;
  select max(salary) from employees;
  select MIN(salary)  from employees;
  select count(salary) from employees;
  select count(*) from employees;

  
  SELECT department_id, avg(SALARY)
    FROM employees
    GROUP BY department_id;
  
Comments