SlideShare a Scribd company logo
Human Resources (HR)
This is the schema that is used in this course. In the Human Resource (HR) records, each employee
has an identification number, email address, job identification code, salary, and manager. Some
employees earn commissions in addition to their salary.
The company also tracks information about jobs within the organization. Each job has an
identification code, job title, and a minimum and maximum salary range for the job. Some
employees have been with the company for a long time and have held different positions within the
company. When an employee resigns, the duration the employee was working for, the job
identification number, and the department are recorded.
The sample company is regionally diverse, so it tracks the locations of its warehouses and
departments. Each employee is assigned to a department, and each department is identified either
by a unique department number or a short name. Each department is associated with one location,
and each location has a full address that includes the street name, postal code, city, state or
province, and the country code.
In places where the departments and warehouses are located, the company records details such as
the country name, currency symbol, currency name, and the region where the country is located
geographically.
HR Schema:

COUNTRIES
DEPARTMENTS
EMPLOYEES
JOB_GRADES
JOB_HISTORY
JOBS
LOCATIONS
REGIONS

Task:

1)
Write a query that displays the last name (with the first letter in uppercase and all the other letters in
lowercase) and the length of the last name for all employees whose name starts with the letters “J,”
“A,” or “M.” (Use Employees table)

2)
Write a query which will print the employees last_name, no.of months worked till date and their
manager name.
Label the columns with the following: Employee – Experience in months – Manager Id

3)
Create a query that displays the first eight characters of the employees’ last names and indicates the
amounts of their salaries with asterisks. Each asterisk signifies a thousand dollars. Sort the data in
descending order of salary. Label the column EMPLOYEES_AND_THEIR_SALARIES.




4)
Create a query to display the last name and the number of weeks employed for all
employees in department 90. Label the number of weeks column TENURE. Truncate
the number of weeks value to 0 decimal places. Show the records in descending order
of the employee’s tenure.
5)
Display each employee’s last name, hire date, and salary review date, which is the first Monday after
six months of service. Label the column REVIEW. Format the dates to appear in the format similar to
“Monday, the Thirty-First of July, 2000.”




6)
Create a report to display the manager number and the salary of the lowest-paid
employee for that manager. Exclude anyone whose manager is not known. Exclude
any groups where the minimum salary is $6,000 or less. Sort the output in descending
order of salary.




7)
Create a query to display the total number of employees and, of that total, the number
of employees hired in 1995, 1996, 1997, and 1998. Create appropriate column
headings.




8)
Create a matrix query to display the job, the salary for that job based on department
number, and the total salary for that job, for departments 20, 50, 80, and 90, giving
each column an appropriate heading.
9)
Create a query that displays the employee last name, job title, department name, salary, and grade for
all employees. (Tables to be used Employees, Departments, Jobs)

10)
Write a query to find the names and hire dates of all the employees who were hired before their
managers, along with their managers’ names and hire dates.




11)
Write a query that displays the employee number and last name of all employees who
work in a department with any employee whose last name contains the letter “u.”
12)
Create a table MY_EMPLOYEE which is a replicate of 'EMPLOYEES' table with all the data.

13)
Add a new column USER_ID to MY_EMPLOYEE table and enforce a unique constraint.

14)
Update the USER_ID column of MY_EMPLOYEE table with the following format.
user_id should contain first letter of the last_name concatenated with first_name of the employee and
the maximum length of the user_id should be 8.

15)
Change the salary to $1,000 for all employees who have a salary less than $900 in MY_EMPLOYEE
table.

16)
Create a view named DEPT50 that contains the employee numbers, employee last names, and
department numbers for all employees in department 50. Label the view columns EMPNO, EMPLOYEE,
and DEPTNO. For security purposes, do not allow an employee to be reassigned to another department
through the view.

17)
Show all employees who were hired on the day of the week on which the highest number of employees
were hired.

18)
Write a query to get the nth highest salary among the employees.
Query should accept a value for n.
If n = 2, then it should retrieve all the employee names who are earning 2nd highest salary among the
employees.

19)
Suppose the primary key constraint has been disabled on employee_id column and users have entered
duplicate employee_id's within the employee table.
Write a query to remove the duplicate rows from the table and preserve the original employee_id which
was existing.

More Related Content

DOCX
All questions
DOC
SQL practice questions set - 2
DOCX
Complex queries in sql
DOCX
Q on subquery
DOCX
SQL-RDBMS Queries and Question Bank
DOC
80 different SQL Queries with output
DOCX
12th information practices mysql practice questions
All questions
SQL practice questions set - 2
Complex queries in sql
Q on subquery
SQL-RDBMS Queries and Question Bank
80 different SQL Queries with output
12th information practices mysql practice questions

What's hot (20)

DOC
Plsql task
DOCX
Top 40 sql queries for testers
DOC
Sql task answers
PDF
SQL practice questions set
DOC
Sql queries with answers
DOCX
Sql Queries
DOC
SQL practice questions - set 3
PDF
Basic Sql Handouts
PDF
DOC
Sql queires
PDF
DBMS 5 | MySQL Practice List - HR Schema
DOCX
Ref cursor
PDF
DBMS 6 | MySQL Practice List - Rank Related Queries
PDF
Using Optimizer Hints to Improve MySQL Query Performance
PPTX
Oracle: Joins
PDF
SQL Functions and Operators
PPT
SQL subquery
PPT
Sql query [select, sub] 4
PPTX
Oracle Index
PDF
Advanced MySQL Query Tuning
Plsql task
Top 40 sql queries for testers
Sql task answers
SQL practice questions set
Sql queries with answers
Sql Queries
SQL practice questions - set 3
Basic Sql Handouts
Sql queires
DBMS 5 | MySQL Practice List - HR Schema
Ref cursor
DBMS 6 | MySQL Practice List - Rank Related Queries
Using Optimizer Hints to Improve MySQL Query Performance
Oracle: Joins
SQL Functions and Operators
SQL subquery
Sql query [select, sub] 4
Oracle Index
Advanced MySQL Query Tuning
Ad

Similar to Sql task (20)

PPTX
SQL case study Analysis PPT by Radhika Kashidd
PDF
Sql queries questions and answers
PDF
Introduction to Databases - Assignment_1
PDF
Divyansh Mehta,BCA Final Year 2015 ,Dezyne E'cole College
DOC
PDF
Simran kaur,BCA Final Year 2015
DOCX
Part 1 - Microsoft AccessView GlossaryUse Access to create a.docx
DOCX
Hands on Assignment for retrieving data using the SQL SELECT statement.docx
PDF
You are required to develop a simple database application fo.pdf
PDF
SQL Practice Question set
DOCX
Add a new check on the emp table to make sure that any new employee in.docx
PDF
Nikhil Khandelwal BCA 3rd Year
PDF
What’s New in HR Analytics from 7.9.6.4 to 11.1.1.x and What You Need to Know
PPT
James Colby Maddox Business Intellignece and Computer Science Portfolio
PPTX
Hr erpnext
PDF
_MITRA PAYROLL Final ppt..pdf
PPT
Sql Portfolio(March 31)
DOCX
AimTo give you practical experience in database modelling, no.docx
DOC
Plsql task answers
SQL case study Analysis PPT by Radhika Kashidd
Sql queries questions and answers
Introduction to Databases - Assignment_1
Divyansh Mehta,BCA Final Year 2015 ,Dezyne E'cole College
Simran kaur,BCA Final Year 2015
Part 1 - Microsoft AccessView GlossaryUse Access to create a.docx
Hands on Assignment for retrieving data using the SQL SELECT statement.docx
You are required to develop a simple database application fo.pdf
SQL Practice Question set
Add a new check on the emp table to make sure that any new employee in.docx
Nikhil Khandelwal BCA 3rd Year
What’s New in HR Analytics from 7.9.6.4 to 11.1.1.x and What You Need to Know
James Colby Maddox Business Intellignece and Computer Science Portfolio
Hr erpnext
_MITRA PAYROLL Final ppt..pdf
Sql Portfolio(March 31)
AimTo give you practical experience in database modelling, no.docx
Plsql task answers
Ad

More from Nawaz Sk (6)

DOCX
Tables
DOCX
Oracle order management implementation manual
DOCX
Forall & bulk binds
PDF
R12 Shipping Execution User guide
PDF
121poug
PDF
121ontapi
Tables
Oracle order management implementation manual
Forall & bulk binds
R12 Shipping Execution User guide
121poug
121ontapi

Recently uploaded (20)

PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
GDM (1) (1).pptx small presentation for students
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
RMMM.pdf make it easy to upload and study
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
Microbial disease of the cardiovascular and lymphatic systems
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Supply Chain Operations Speaking Notes -ICLT Program
Anesthesia in Laparoscopic Surgery in India
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
VCE English Exam - Section C Student Revision Booklet
Abdominal Access Techniques with Prof. Dr. R K Mishra
Microbial diseases, their pathogenesis and prophylaxis
O5-L3 Freight Transport Ops (International) V1.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
GDM (1) (1).pptx small presentation for students
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Module 4: Burden of Disease Tutorial Slides S2 2025
RMMM.pdf make it easy to upload and study
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf

Sql task

  • 1. Human Resources (HR) This is the schema that is used in this course. In the Human Resource (HR) records, each employee has an identification number, email address, job identification code, salary, and manager. Some employees earn commissions in addition to their salary. The company also tracks information about jobs within the organization. Each job has an identification code, job title, and a minimum and maximum salary range for the job. Some employees have been with the company for a long time and have held different positions within the company. When an employee resigns, the duration the employee was working for, the job identification number, and the department are recorded. The sample company is regionally diverse, so it tracks the locations of its warehouses and departments. Each employee is assigned to a department, and each department is identified either by a unique department number or a short name. Each department is associated with one location, and each location has a full address that includes the street name, postal code, city, state or province, and the country code. In places where the departments and warehouses are located, the company records details such as the country name, currency symbol, currency name, and the region where the country is located geographically.
  • 2. HR Schema: COUNTRIES DEPARTMENTS EMPLOYEES JOB_GRADES JOB_HISTORY JOBS LOCATIONS REGIONS Task: 1) Write a query that displays the last name (with the first letter in uppercase and all the other letters in lowercase) and the length of the last name for all employees whose name starts with the letters “J,” “A,” or “M.” (Use Employees table) 2) Write a query which will print the employees last_name, no.of months worked till date and their manager name. Label the columns with the following: Employee – Experience in months – Manager Id 3) Create a query that displays the first eight characters of the employees’ last names and indicates the amounts of their salaries with asterisks. Each asterisk signifies a thousand dollars. Sort the data in descending order of salary. Label the column EMPLOYEES_AND_THEIR_SALARIES. 4) Create a query to display the last name and the number of weeks employed for all employees in department 90. Label the number of weeks column TENURE. Truncate the number of weeks value to 0 decimal places. Show the records in descending order of the employee’s tenure.
  • 3. 5) Display each employee’s last name, hire date, and salary review date, which is the first Monday after six months of service. Label the column REVIEW. Format the dates to appear in the format similar to “Monday, the Thirty-First of July, 2000.” 6) Create a report to display the manager number and the salary of the lowest-paid employee for that manager. Exclude anyone whose manager is not known. Exclude any groups where the minimum salary is $6,000 or less. Sort the output in descending order of salary. 7) Create a query to display the total number of employees and, of that total, the number of employees hired in 1995, 1996, 1997, and 1998. Create appropriate column headings. 8) Create a matrix query to display the job, the salary for that job based on department number, and the total salary for that job, for departments 20, 50, 80, and 90, giving each column an appropriate heading.
  • 4. 9) Create a query that displays the employee last name, job title, department name, salary, and grade for all employees. (Tables to be used Employees, Departments, Jobs) 10) Write a query to find the names and hire dates of all the employees who were hired before their managers, along with their managers’ names and hire dates. 11) Write a query that displays the employee number and last name of all employees who work in a department with any employee whose last name contains the letter “u.”
  • 5. 12) Create a table MY_EMPLOYEE which is a replicate of 'EMPLOYEES' table with all the data. 13) Add a new column USER_ID to MY_EMPLOYEE table and enforce a unique constraint. 14) Update the USER_ID column of MY_EMPLOYEE table with the following format. user_id should contain first letter of the last_name concatenated with first_name of the employee and the maximum length of the user_id should be 8. 15) Change the salary to $1,000 for all employees who have a salary less than $900 in MY_EMPLOYEE table. 16) Create a view named DEPT50 that contains the employee numbers, employee last names, and department numbers for all employees in department 50. Label the view columns EMPNO, EMPLOYEE, and DEPTNO. For security purposes, do not allow an employee to be reassigned to another department through the view. 17) Show all employees who were hired on the day of the week on which the highest number of employees were hired. 18) Write a query to get the nth highest salary among the employees. Query should accept a value for n. If n = 2, then it should retrieve all the employee names who are earning 2nd highest salary among the employees. 19) Suppose the primary key constraint has been disabled on employee_id column and users have entered duplicate employee_id's within the employee table. Write a query to remove the duplicate rows from the table and preserve the original employee_id which was existing.