Practice SQL Questions 31-51HR Schema with Solutions
31. From the following tables, write a SQL query to find those employees whose salaries exceed 50% of their department's total salary bill. Return first name, last name. with calc as (select department_id, sum(salary)/2 as half_total_salary from employees group by department_id) select e.first_name,e.last_name from employees e join calc c on e.department_id=c.department_id and e.salary>c.half_total_salary; 32. From the following tables, write a SQL query to find those employees who are managers. Return all the fields of employees table. select * from employees where employee_id in ( select distinct manager_id from employees where manager_id is not null); 33. From the following table, write a SQL query to find those employees who manage a department. Return all the fields of employees table. select * from employees where employee_id in (select distinct manager_id from employees); 34. From the following table, write a SQL query to search for employee...