Created
April 1, 2019 00:15
-
-
Save mzalazar/86abca876e8d66cb78d66e5b41688dc4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Database table install instructions */ | |
https://dev.mysql.com/doc/employee/en/employees-installation.html | |
/* Return employee record with max salary */ | |
SELECT * | |
FROM employee | |
WHERE salary = (SELECT MAX(salary) FROM employee) | |
/* Select highest salary in employee table */ | |
SELECT MAX(salary) | |
FROM employee | |
/* Select 2nd highest salary in employee table */ | |
SELECT MAX(salary) | |
FROM employee | |
WHERE salary NOT IN(SELECT MAX(salary) FROM employee) | |
/* select range of employees based on id */ | |
SELECT * | |
FROM employee | |
WHERE employee_id BETWEEN 2003 AND 2008 | |
/* Return employee name, highest salary and department */ | |
SELECT e.first_name, e.last_name, e.salary, d.department_name | |
FROM employee e | |
INNER JOIN department d ON (e.department_id = d.department_id) | |
WHERE salary IN (SELECT MAX(salary) FROM employee) | |
/* Return highest salary, employee name, department name for each department */ | |
SELECT e.first_name, e.last_name, e.salary, d.department_name | |
FROM employee e | |
INNER JOIN department d ON (e.department_id = d.department_id) | |
WHERE salary IN (SELECT MAX(salary) FROM employee GROUP BY department_id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment