SQL Subquery Exercises: Display the name , salary, department id for those employees who earn such amount of salary which is the smallest salary of any of the departments
SQL SUBQUERY: Exercise-3 with Solution
Write a query to display the name ( first name and last name ), salary, department id for those employees who earn such amount of salary which is the smallest salary of any of the departments.
Sample table: employees
SELECT first_name, last_name, salary, department_id FROM employees WHERE salary IN ( SELECT MIN(salary) FROM employees GROUP BY department_id );
first_name last_name salary department_id Neena Kochhar 17000.00 90 Lex De Haan 17000.00 90 Bruce Ernst 6000.00 60 Diana Lorentz 4200.00 60 Luis Popp 6900.00 100 Karen Colmenares 2500.00 30 Shanta Vollman 6500.00 50 James Marlow 2500.00 50 TJ Olson 2100.00 50 Joshua Patel 2500.00 50 Peter Vargas 2500.00 50 Peter Tucker 10000.00 80 Oliver Tuvault 7000.00 80 Janette King 10000.00 80 Sarath Sewall 7000.00 80 Harrison Bloom 10000.00 80 Sundita Kumar 6100.00 80 Kimberely Grant 7000.00 0 Martha Sullivan 2500.00 50 Nandita Sarchand 4200.00 50 Randall Perkins 2500.00 50 Jennifer Whalen 4400.00 10 Pat Fay 6000.00 20 Susan Mavris 6500.00 40 Hermann Baer 10000.00 70 William Gietz 8300.00 110
Contribute your code and comments through Disqus.
Previous: Write a query to display the name ( first name and last name ), salary, department id, job id for those employees who works in the same designation as the employee works whose id is 169.
Next: Write a query to display the employee id, employee name (first name and last name ) for all employees who earn more than the average salary.
What is the difficulty level of this exercise?