Professional Documents
Culture Documents
Mid - Term - Exam - DB2 1895093
Mid - Term - Exam - DB2 1895093
Mid - Term - Exam - DB2 1895093
__________1895093__________________________
The following is the structure of the tables provided by Oracle in Human Resource Schema (HR).
1. Connect to HR user and create tables in Figure 1 as a full copy from HR Schema tables (structure + data). The
table name, which you will create are: REGIONS_DB2, DEPARTMENTS_DB2, EMPLOYEES_DB2,
COUNTRIES_DB2, JOBS_DB2, LOCATIONS_DB2, JOB_HISTORY_DB2).
For the rest of questions, you will be using tables created in Question #1
2. Add a constraint ( table level) to table EMPLOYEES_DB2 where Column « Phone_number » must include at
least 8 numbers.
3. Add a constraint ( table level) to table JOBS_DB2 so MIN_SALARY will be always inferior to MAX_SALARY
4. Insert the next fields in JOBS_DB2 and show the answer
Job_id: 890 , Job_Title: DB_Exam, MIN_SALARY: 3500, MAX_SALARY: 2300
xx3. Display jobs where the minimum salary is less than salary of employee 105
SELECT job_title, first_name || ' ' || last_name AS Employee_name,
max_salary-salary AS salary_difference
FROM employees
NATURAL JOIN jobs;
.
xx3. Write a query in SQL to display the first name, last name, department number and department name, for all
employees for departments 80 or 40.
xx3. Write a query in SQL to display job title, full name (first and last name ) of employee, and the difference
between maximum salary for the job and salary of the employee.
xx6. Display number of employees joined in each year into department 30.
xx6. Write a query in SQL to display the first and last name and salary for those employees who earn less than the
employee earn whose number is 182
xx6. Write a query in SQL to display the name of the country, city, and the departments which are running there.
xx7. Display job id, department id and sum of salary by including al possible dimensions.
xx7. Write a query in SQL to display the first name of all employees including the first name of their manager.
xx7. Write a query in SQL to display department name and the full name (first and last name) of the manager.
xx8. Display employee name and job title of jobs where salary of employee is between minimum and maximum
salary for job.
xx8. Write a query in SQL to display the department name, city, and state province for each department
xx8. Write a query in SQL to display job title and average salary of employees.
xx9. Display how many employees have commission percentage and how many do not have.
xx9. Write a query in SQL to display the first name, last name, department number and name, for all employees
who have or have not any department
xx9. Write a query in SQL to display the sum of salaries of all employees grouped by department
xx0. Display first name, job title, department name of employees who joined on 28th Feb.
xx0. Write a query in SQL to display the details of jobs which was done by any of the employees who is presently
earning a salary on and above 12000.
xx0. Write a query in SQL to display the first name of all employees and the first name of their manager including
those who does not working under any manager
ANNEXE: