HR Schema Queries and PL SQL Programs

September 29, 2022 | Author: Anonymous | Category: N/A
Share Embed Donate


Short Description

Download HR Schema Queries and PL SQL Programs...

Description

 

The following is the structure of the tables provided by Oracle in Human Resource Schema (HR).

Note:

Columns in RED color indicate primary key(s).

Queries 1. 2. 3. 4. 5. 6. 7.

Display Display details details of jobs jobs where the the minimum minimum salary salary is greater greater than than 10000. Display Display the first first name name and join date date of the employees employees who joined joined between between 2002 and 2005. 2005. Display Display first first name and join date date of the employees employees who is either either IT Programmer Programmer or or Sales Man. Man. Display Display employees employees who joined joined after after 1st 1st January January 2008. 2008. Display Display details details of employee employee with ID 150 150 or 160. Display Display first name, name, salary, salary, commission commission pct, and hire date for employees employees with with salary less less than 10000. Display Display job Title, the differenc differencee between minimum minimum and maximum maximum salaries salaries for jobs with with max salary in the range 10000 to 20000. 8. Display Display first first name, name, salary, salary, and round the the salary salary to thousan thousands. ds. 9. Display Display details details of jobs in in the descendi descending ng order of the title. title. 10. Display Display employees employees where where the first first name or or last name name starts starts with with S. 11. Display Display employees employees who joined joined in in the month of May. May. 12. Display Display details details of the employees where where commis commission sion percentage percentage is null and salary salary in the range 5000 to 10000 and department is 30. 13. Display Display first first name name and date date of first first salary salary of the employe employees. es. 14. Display Display first first name name and experience experience of the employees employees.. 15. Display Display first first name name of employees employees who who joined joined in 2001.

http://www.srikanthtechnologies.com/orac http://www.srikant htechnologies.com/oracle/dec9/hrqueries.htm le/dec9/hrqueries.htmll  

16. Display Display first first name and last name name after co converti nverting ng the first first letter letter of each name to upper upper case and the rest rest to lower case. 17. Displa Display y the ffirs irstt word word in job job title. title. 18. Display Display the length of first first name for employees employees where last last name contain character character ‘b’ after after 3rd position. position. 19. Display Display first first name in upper case case and email address address in lower lower case for employees employees where where the first first name and email address are same irrespective of the case. 20. Display Display employees employees who joined joined in the the current current year. 21. Display Display the number number of days between between system system date and 1st 1st January January 2011. 22. Display Display how many many employees employees joined joined in in each month month of the current current year. year. 23. Display Display manager manager ID and and number number of employees employees managed by the manager. manager. 24. Display Display employee employee ID and the date date on which which he ended ended his previous previous job. job. 25. Display Display number number of employees employees joined after 15th of the month. month. 26. Display Display the country country ID and number number of cities cities we have in the countr country. y. 27. Display Display average salary salary of employees employees in in each department department who have commiss commission ion percentage. percentage. 28. Display Display job ID, number of employees, employees, sum of salary, salary, and diff difference erence between between highest highest salary and lowest lowest salary salary of the employees of the job. 29. Display Display job ID ID for jobs jobs with with average average salary salary more more than 10000. 10000. 30. Display Display years years in which which more more than than 10 employees employees joined. joined. 31. Display Display departments departments in which which more than than five employees employees have commiss commission ion percentage. percentage. 32. Display Display employee employee ID for employe employees es who did did more than than one job in the the past. 33. Display Display job ID of jobs jobs that were were done by more more than 3 employee employeess for more more than 100 days. days. 34. Display Display department department ID, year, year, and Number Number of of employees employees joined. joined. 35. Display Display departments departments where where any manager manager is managing managing more than than 5 employees. employees. 36. Change salary salary of employe employeee 115 to 8000 if the existing existing salary salary is less than than 6000. 37. Insert Insert a new employee employee into into employees employees with with all the require required d details. details. 38 38.. Dele Delete te depa depart rtme ment nt 20. 20. 39. Change job ID of employee employee 110 to to IT_PROG if the the employee employee belongs to to department department 10 and the existing existing job ID does not start with IT. 40. Insert Insert a row into department departmentss table with with manager ID ID 120 and location location ID in any location location ID for ci city ty Tokyo. 41. Display Display department department name name and number number of employees employees in the the department. department. 42. Display Display job title, title, employee employee ID, number of days days between between ending date and and starting starting date for all jobs jobs in department 30 from job history. 43. Display Display departme department nt name name and manager first first name. name. 44. Display Display departme department nt name, name, manager manager name, and city. city. 45. Display Display country country name, city, and departm department ent name. name. 46. Display Display job title, departme department nt name, employee employee last name, startin starting g date for all jobs from 2000 2000 to 2005. 47. Display Display job title title and av average erage salary salary of employe employees es 48. Display Display job title, employee employee name, and the differen difference ce between maximum maximum salary salary for the job and salary of the employee. 49. Display Display last name, job title title of employees employees who have commission commission percentage percentage and belongs to departmen departmentt 30. 50. Display Display details details of jobs that were were done by any employee employee who is currentl currently y drawing more more than 15000 of salary. salary. 51. Display Display department department name, manager manager name, and salary salary of the manager for all manag managers ers whose experienc experiencee is more than 5 years. 52. Display Display employee employee name name if the the employee employee joined joined before before his manager. manager. 53. Display Display employee employee name, job title title for the jobs jobs employee employee did in the past past where the job was was done less than than six months. 54. Display Display employee employee name name and country country in which which he he is working. working. 55. Display Display department department name, average average salary and number number of employees employees with commissio commission n within the department department.. 56. 57. 58. 59. 60. 61.

Display Display the month in which which more than than 5 employees joined joined in any departme department nt located located in Sydney. Display Display details details of departments departments in which which the maximum maximum salary salary is more than than 10000. Display Display details details of departme departments nts managed managed by by ‘Smith’. ‘Smith’. Display Display jobs into which which employees employees joined in the current current year. Display Display employees employees who did did not do do any job job in the the past. past. Display Display job title title and average average salary salary for employees employees who did a job in in the past. past.

http://www.srikanthtechnologies.com/orac http://www.srikant htechnologies.com/oracle/dec9/hrqueries.htm le/dec9/hrqueries.htmll  

62. Display Display country country name, city, city, and number of departmen departments ts where departm department ent has more than than 5 employees. employees. 63. Display Display details details of manager manager who manages manages more more than than 5 employees. employees. 64. Display Display employee name, name, job title, start start date, and end date of past jobs jobs of all employees employees with commissio commission n  percentage null. 65. Display Display the departmen departments ts into into which no employee employee joined joined in last last two years. years. 66. Display Display the details details of department departmentss in which the max max salary is greater greater than than 10000 for employees employees who did did a job in the past. 67. Display Display details details of current current job for employees employees who worked worked as IT Programmers Programmers in in the past. 68. Display Display the details details of employees employees drawing drawing the highest highest salary salary in the departmen department. t. 69. Display Display the city of of employee employee whose whose employee employee ID is is 105. 70. Display Display third third highest highest salary salary of all all employees employees

PL/SQL Programs 1. Write Write a program program to interch interchange ange the salaries salaries of employee employee 120 and 122. 2. Increase Increase the salary salary of employee 115 based on the following following conditions conditions:: If experience experience is more than 10 years, increase salary by 20% If experience is greater than 5 years, increase salary by 10% Otherwise 5% Case by Expression: 3. Change commissi commission on percentage percentage as follows follows for employee employee with with ID = 150. If salary salary is more th than an 10000 then commission is 0.4%, if Salary is less than 10000 but experience is more than 10 years then 0.35%, if salary is less than 3000 then commission is 0.25%. In the remaining cases commission is 0.15%. 4. Find out the name name of the employee employee and name of the departmen departmentt for the employee employee who is managing managing for  employee 103. 5. Dis play y the mi miss ssing ing employee empl oyee IDs. IDs. m number of employees 6. Displa Display Displ ay year in which whi ch maximum maximu employees joined joined along along with how many many joined in each month month in that year. 7. Change salary salary of employee employee 130 to the salary salary of the employee employee with with first name name ‘Joe’. If Joe Joe is not found found then take average salary of all employees. If more than one employee with first name ‘Joe’ is found then take the least salary of the employees with first name Joe. 8. Display Display Job Title Title and Name Name of the Employee Employee who joined joined the the job first first day. 9. Display Display 5th 5th and 10th employees employees in in Employees Employees table. table. 10. Update salary salary of an employee based based on department department and commission commission percentage. percentage. If department department is 40 increase increase salary by 10%. If department is 70 then 15%, if commission is more than .3% then 5% otherwise 10%. 11. Create a function function that that takes departme department nt ID and returns returns the name of the manager manager of the departm department. ent. 12. Create a function function that that takes employee employee ID and return return the number number of jobs done done by the employee employee in the past. 13. Create a procedure procedure that that takes departme department nt ID and changes changes the manager ID ID for the department department to to the employee employee in the department with highest salary. (Use Exceptions). 14. Create a function function that that takes a manager manager ID and return return the names of employe employees es who report report to this manager. manager. The names must be returned as a string with comma separating names. 15. Ensure no no changes can can be made to EMPLOYE EMPLOYEES ES table table before 6am 6am and after after 10pm in a day. day. 16. Create a Trigger Trigger to ensure ensure the salary salary of the the employee employee is not decrease decreased. d. 17. Create a trigger trigger to ensure ensure the employee employee and manager manager belongs belongs to the same departmen department. t.

 Note: This trigger need to read the row that is being modified, which causes mutating pr explained at : Work around around for mutatin mutating g problem problem in Oracle Oracle Triggers Triggers. Please check it out.

18. Whenever Whenever the job is changed for an employee employee write the followin following g details into into job history. history. Employee ID, old  job ID, old department ID, hire of the employee start date,be system date forof end date. already present for employee jobdate history then the startfor date should the end date that rowBut +1.if a row is

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF