Professional Documents
Culture Documents
8 SQL Answer
8 SQL Answer
8 SQL Answer
/*Show last name, job code, hire date and salary for non VP’s who have been hired AFTER June 1995
and who are earning outside the range from $8,000 to $14,000.
Sort the output according to the job firstly and then by top salaries.
SELECT
last_name AS "Lname",
salary AS "Pay"
FROM employee
ORDER BY 2, 4 DESC;
-- Question 2:
/*Show employee’s last name, job and salary if they earn less than the average amount earned in the
city of OXFORD
and if their job is NOT related to Marketing (it does not start on MK)
Sort the output according to the top salaries first and then by the last name.
Use just a Subquery method (multiple times). Do not use a Join method !
This study source was downloaded by 100000844792446 from CourseHero.com on 10-18-2022 03:38:37 GMT -05:00
https://www.coursehero.com/file/87571099/dbs311-midtermdocx/
LAST_NAME JOB_ID SALARY
SELECT
last_name,
job_id,
salary
FROM employee
(SELECT AVG(salary)
FROM employee
WHERE department_id IN
(SELECT department_id
FROM department
WHERE location_id IN
(SELECT location_id
FROM location
ORDER BY 3 DESC, 1;
-- Question 3;
/*Which jobs can be found in the company and how many people do these jobs?
This report should include only departments for IT and MARKETING and will show only those jobs that
involve more than two persons.
Two components displayed should have headings Position and # of People, while the output will show
firstly the job positions with most people.
This study source was downloaded by 100000844792446 from CourseHero.com on 10-18-2022 03:38:37 GMT -05:00
https://www.coursehero.com/file/87571099/dbs311-midtermdocx/
Here are shown headings and first row:
Position # of People
------------- ------------------
IT_PROG 3 */
SELECT
job_id AS "Postion",
FROM employee
GROUP BY job_id
ORDER BY 2 DESC;
-- Question 4:
/*Display last name and job id of employees who are holding jobs that do not exist in
LAST_NAME JOB_ID
------------------ ---------------
De Haan AD_VP
Hartstein MK_MAN*/
SELECT
last_name,
job_id
FROM employee
This study source was downloaded by 100000844792446 from CourseHero.com on 10-18-2022 03:38:37 GMT -05:00
https://www.coursehero.com/file/87571099/dbs311-midtermdocx/
WHERE job_id IN
(SELECT job_id
FROM employee
MINUS
SELECT job_id
FROM job_history)
ORDER BY last_name;
-- Question 5:
/*
*/
This study source was downloaded by 100000844792446 from CourseHero.com on 10-18-2022 03:38:37 GMT -05:00
https://www.coursehero.com/file/87571099/dbs311-midtermdocx/
Powered by TCPDF (www.tcpdf.org)