Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

select employees.name ,employees.

surname,
departments.dept_name ,departments.address from employees join departments on
employees.dept_id = departments.dept_id where employees.dept_id is not null ;
select 'Employee ' || employees.name || ' ' || employees.surname || ' works in '
|| departments.dept_name || ' located at ' || departments.ADDRESS AS sentence from
employees join departments on employees.dept_id = departments.dept_id where
employees.dept_id is not null;
select employees.surname , employees.salary from employees join departments on
employees.dept_id = departments.dept_id where departments.address = '47TH STR';
select count(employees.emp_id) as
employees_at_47th_str,round(avg(employees.salary), 2) as avg_salary from employees
join departments on employees.dept_id = departments.dept_id where
departments.address = '47TH STR';
select employees.surname, employees.job, employees.salary, jobs.min_salary as
job_min_salary, jobs.max_salary as job_max_salary from employees join jobs on
employees.job = jobs.name;
select employees.surname,employees.job,employees.salary, jobs.min_salary as
job_min_salary, jobs.max_salary as job_max_salary from employees join jobs on
employees.job = jobs.name where employees.salary<jobs.min_salary and
employees.salary>jobs.max_salary;
select employees.surname, employees.job, employees.salary, jobs.min_salary as
job_min_salary , jobs.max_salary as job_max_salary from employees join jobs on
employees.job = jobs.name where employees.job in ('ASSISTANT', 'SECRETARY') and
employees.salary between jobs.min_salary and jobs.max_salary;
select departments.dept_name as department, count(employees.emp_id) as
employees_at_dept, sum(employees.salary) as salaries_at_dept from departments join
employees on departments.dept_id = employees.dept_id group by
departments.dept_name;
select departments.dept_name as department, count(employees.emp_id) as
employees_at_dept, sum(employees.salary) as salaries_at_dept from departments join
employees on departments.dept_id = employees.dept_id group by departments.dept_name
having count(employees.emp_id) >= 2;
select departments.dept_name as department, case when count(employees.emp_id) <= 2
THEN 'small' when count(employees.emp_id) between 3 and 6 then 'medium' when
count(employees.emp_id) >= 7 then 'big' end as label from departments join
employees on departments.dept_id = employees.dept_id group by
departments.dept_name having count(employees.emp_id) > 0;

You might also like