Professional Documents
Culture Documents
REYES Lab4
REYES Lab4
Midterm Period
Instructions:
- Connect to the SQL Plus or SQL Developer using a database account. Example: ORA2_PDBRAP
- Analyze and perform the problems below and answer it to the best of your ability
- Include screenshots of your complete SQL Statements and the result/s.
- Include a brief description/caption of each image
- There must be your full name for each image (see example below)
- Save your work as SURNAME1_Lab4.DOCX (Ex. Pagaduan_Lab4.DOCX).
- Each item corresponds to one (1) point, total points are 12.
Sample: Questions:
SELECT ROUND(MAX(salary),0)
"Maximum",
ROUND(MIN(salary),0) "Minimum",
ROUND(SUM(salary),0) "Sum",
ROUND(AVG(salary),0) "Average"
FROM employees;
6. Write a query to display the number of
people with the same job.
Output:
Answer:
Query:
FROM employees
GROUP BY job_id;
Answer:
Query:
SELECT MAX(salary) - MIN(salary) AS
DIFFERENCE
FROM employees;
Output:
FROM employees
WHERE manager_id IS NOT NULL
GROUP BY manager_id
HAVING MIN(salary) > 6000
ORDER BY MIN(salary) DESC;
Output:
Answer:
Query:
10. Using the Oracle database, select the
lowest salary, the most recent hire date,
the last name of the person who is at the
top of an alphabetical list of employees,
and the last name of the person who is at
the bottom of an alphabetical list of
employees. Select only employees who
are in departments 50 or 60.
Answer:
Query:
SELECT MIN(salary) “Lowest Salary”, 12. Write a query that will return both the
MAX(hire_date) “Most Recent Hire maximum and minimum average salary
Date”, MIN(last_name) “Top Last Name”, grouped by department from the
MAX(last_name) “Bottom Last Name” employees table.
FROM employees
GROUP BY department_id;
Output:
11. Write a query that will return the average
of the maximum salaries in each
department for the employees table.
Answer:
Query:
SELECT AVG(MAX(salary))
FROM employees
GROUP BY department_id;
Output: