2 DML Practice
2 DML Practice
HR Schema - ERD
• Show those employee details whose first name starts with the letter s.
• Show those employee details whose first name doesn’t start with the letter s.
• Show those employee details whose first name ends with the letter a.
• Show those employee details whose first name contains da as substring.
• Show those employee details whose first name starts with s and ends with a.
• Show those employee details whose first name either starts with s or starts with m.
• Show those employee details whose first name contains the letter o and a.
• Show those employee details whose first name contains the letter o followed by the letter a.
• Show those department details whose location_id is within the range 1000 to 2000 inclusive.
• Show those employee details whose salary is within the range 10000 to 20000 inclusive.
• Show those employee details whose hire_date is within the range ‘1987-01-01’ to ‘1987-06-30’ inclusive.
• Show those employee details whose department_id is not within the range 50 to 60 inclusive.
• Show those job details where the difference between max_salary and min _salary is within the range 5000 to
10000 inclusive.
• Show those job_history details where the end_date is within the range ‘1998-12-01’ to ‘1998-12-31’ inclusive.
• Show all the past employees employee id, start date, job id and his group name from the job_history table:
Determine the group name as below:
• Show the department id, department name, location id and location group name from the departments table:
Determine the location group name as below:
• From the jobs table show the job id, job title, and job group name.
Determine the job group name based on the following criteria:
• Show the EMPLOYEE_ID, START_DATE, END_DATE and SENIORITY_LEVEL from the job_history table where the
SENIOR_LEVEL will be calculated as follow:
• Show the JOB_ID, JOB_TITLE and SALARY_RANGE_CLASS from the jobs table where the SALARY_RANGE_CLASS
will be calculated as follow:
• Show all the employees employee id and their short name in lowercase format.
Short name format: first 3 letters from the first name followed by an underscore and then followed by the first 3
letters of last name.
• Show all those employee details whose name is a palindrome.
• Show all the employees employee id and email (i.e. add ‘@gmail.com’ at the end of each email).
• Show all the employees first name and phone number.
Phone number format: 515.xxx.xxx7 i.e. only show the first 4 characters and the last character and hide the
intermediate characters with xxx.xxx
• Show all the employees employee id, email and full name.
Full name format: first_name<SPACE>last_name
Also show the full name in 20 characters if necessary right pad with necessary no of spaces.
• Show those location details from locations table whose postal code consists at most 5 characters and the first
two digits of its postal code is between 50 to 99 inclusive.
• Show all the employees employee id, first name and his salary in “10 thousand 5 hundred and 12 taka only”
format.
• For each job, show the job id, job title and how much greater the max_salary from min_salary in percentage
format.
Note: Show the output in 2 decimal points
%greater=(max_salary-min_salary)*100/min_salary
• Show all those job details from jobs table whose salary range (i.e. max_salary-min_salary) is greater than 8000
and the job title contains the word ‘Manager’.
• Show all the employees email, hire date in “January 4th, 1987” format.
• Show all the employees email, hire date in “Jan 1987, 04” format.
• Show all the employees email, hire date in “1st Aug, 87 05:10 PM” format.
• Show all the employees email, hire date in “15 Jan, 2019 Tuesday 14:10” format.
• Show those employees first name, email, phone number who is hired after the date “05 May, 1987 00:00 AM”.
• Show those employees first name, email, phone number who is hired before the date “1st June 1987 11:01 PM”.
• Show all the employees employee id and his current job experience (till today) in number of years format.
Note: Show the no of years in 3 decimal points.
• Show all the employees employee id, email and his current job experience in “10 years, 06 months and 15 days”
format.
Note: show the months in two digits format if necessary left pad with 0.
• Show all those employees employee id from the job_history table whose job experience is greater than 5 years.
• For each job_history, show how many days an employee has served during his last month of retirement.
• For each employee, show how many days an employee has served during his first month of joining.
• Show all those employee details who have been hired on the leap day(29th Feb) of any leap year.
• Show all those employee details whose hiring month is either 2/4/6/8.
• Show all those employee details who have joined either in the year of 1997 or in the month of February(any
year).
• Show all the employees first name, department id, manager id and his updated join date that is one week before
the real join date.
• From the employees table, show all the employees employee id, join date and estimated retirement date that is
35 years after his join date.
• Show all the employees first name, last name, email, hire date, salary in descending order of salary. If multiple
employees receive the same salary then also sort them based on the alphabetical order of their first name.
• Show all the employees employee id and their join date in such a way that the senior most employee comes first.
If multiple employees have the same join date then also sort them based on the descending order of their
department id.
• Show all the employees first name, email and phone number. Order the output based on the descending order of
first 3 digits of their phone number.
• Show all the employees employee id, email, hire year (only the year portion) and hire month (show the full
month name). Show the output from most recent hired employee to old employees.
• Show the highest salary holder employee details from the employees table.
• Show the top 10 most experienced employee details from the employees table.
• Show the 2nd lowest salary range (i.e. max_salary-min_salary) job details from the jobs table.
• Show the top 3 lowest salary holder employee details from department number 60.
• Among the employees supervised by manager id 108, find out the 2nd highest salary holder employee details.
• Among the employees whose job type is ‘ST_CLERK’, show the highest experienced employee id from the
job_history table.