The document contains 7 SQL queries that select data from an employees table. The queries retrieve employee details like name, id and department, lowest salaries by department, employees in a specific department with commissions below another, departments with all salaries under 30k, employees with lower commissions than others in their department, managers without low-paid staff, and lowest-paid employees by manager.
Original Description:
Original Title
21301591 Abdullah Cse370 05 Lab Assignment02 Fall23
The document contains 7 SQL queries that select data from an employees table. The queries retrieve employee details like name, id and department, lowest salaries by department, employees in a specific department with commissions below another, departments with all salaries under 30k, employees with lower commissions than others in their department, managers without low-paid staff, and lowest-paid employees by manager.
The document contains 7 SQL queries that select data from an employees table. The queries retrieve employee details like name, id and department, lowest salaries by department, employees in a specific department with commissions below another, departments with all salaries under 30k, employees with lower commissions than others in their department, managers without low-paid staff, and lowest-paid employees by manager.
select first_name, last_name, email, phone_number, hire_date, department_id from
employees where hire_date = (select max(hire_date) from employees);
2. select first_name, last_name, employee_id, phone_number, salary, department_id from
employees where (department_id, salary) in (select department_id, min(salary) from employees group by department_id);
3. select first_name, last_name, employee_id, commission_pct, department_id from employees
where department_id = 'DPT007' and commission_pct < all(select commission_pct from employees where department_id = 'DPT005');
4. select department_id, count(employee_id) from employees group by department_id having
max(salary)<30000;
5. select department_id,job_id,commission_pct FROM employees e1 WHERE EXISTS
(SELECT * FROM employees e2 WHERE e1.department_id=e2.department_id and e1.job_id! =e2.job_id and e1.commission_pct<e2.commission_pct) GROUP BY department_id;
6.SELECT DISTINCT manager_id FROM employees e1 WHERE NOT EXISTS (SELECT *
FROM employees e2 WHERE e1.manager_id=e2.manager_id and e2.salary<30000); 7.SELECT first_name,last_name, employee_id,email,salary,department_id, commission_pct FROM employees WHERE (commission_pct,manager_id) IN (SELECT MIN(commission_pct),manager_id FROM employees GROUP BY manager_id);