0% found this document useful (0 votes)
577 views

Empi D Empfnam E Emplnam E Departme NT Projec T Address Dob Gende R

The document contains details of employees in two tables: EmployeeInfo and EmployeePosition. EmployeeInfo contains employee details like name, department, project, gender, address, date of birth. EmployeePosition contains employee id, position, date of joining, salary. 23 questions are asked to write SQL queries on these tables to fetch various details like employee names, count of employees in a department, salary range, names starting with S, top 3 records etc.

Uploaded by

Sandesh Ahir
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
577 views

Empi D Empfnam E Emplnam E Departme NT Projec T Address Dob Gende R

The document contains details of employees in two tables: EmployeeInfo and EmployeePosition. EmployeeInfo contains employee details like name, department, project, gender, address, date of birth. EmployeePosition contains employee id, position, date of joining, salary. 23 questions are asked to write SQL queries on these tables to fetch various details like employee names, count of employees in a department, salary range, names starting with S, top 3 records etc.

Uploaded by

Sandesh Ahir
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Employee Info Table:

EmpI EmpFnam EmpLnam Departme Projec Gende


Address DOB
D e e nt t r
Hyderabad(HY 01/12/197
1 Sanjay Mehra HR P1 M
D) 6
02/05/196
2 Ananya Mishra Admin P2 Delhi(DEL) F
8
01/01/198
3 Rohan Diwan Account P3 Mumbai(BOM) M
0
Hyderabad(HY 02/05/199
4 Sonia Kulkarni HR P1 F
D) 2
03/07/199
5 Ankit Kapoor Admin P2 Delhi(DEL) M
4

Employee Position Table:

EmpID EmpPosition DateOfJoining Salary


1 Manager 01/05/2019 500000
2 Executive 02/05/2019 75000
3 Manager 01/05/2019 90000
2 Lead 02/05/2019 85000
1 Executive 01/05/2019 300000

Q1. Write a query to fetch the EmpFname from the EmployeeInfo table in
upper case and use the ALIAS name as EmpName.

Q2. Write a query to fetch the number of employees working in the


department ‘HR’.

Q3. Write q query to find all the employees whose salary is between
50000 to 100000.

Q4. Write a query to find the names of employees that begin with ‘S’

Q5. Write a query to fetch top 3 records.

Q6. Write a query to retrieve the EmpFname and EmpLname in a single column
as “FullName”. The first name and the last name must be separated with space.

Q7. Write a query find number of employees whose DOB is between 02/05/1970
to 31/12/1975 and are grouped according to gender
Q8. Write a query to fetch all the records from the EmployeeInfo table ordered
by EmpLname in descending order and Department in the ascending order.

Q9. Write a query to fetch details of employees whose EmpLname ends with an
alphabet ‘A’ and contains five alphabets.

Q10. Write a query to fetch details of all employees excluding the employees with
first names, “Sanjay” and “Sonia” from the EmployeeInfo table.

Q11. Write a query to fetch details of employees with the address as


“DELHI(DEL)”.

Q12. Write a query to fetch all employees who also hold the managerial position.

Q13. Write a query to fetch the department-wise count of employees sorted by


department’s count in ascending order.

Q14. Write a query to calculate the even and odd records from a table.

Q15. Write a SQL query to retrieve employee details from EmployeeInfo table


who have a date of joining in the EmployeePosition table.

Q16. Write a query to find the Nth highest salary from the table without using
TOP/limit keyword.

Q17. Write a query to retrieve the list of employees working in the same
department.

Q18. Write a query to retrieve the last 3 records from the EmployeeInfo table.

Q19. Write a query to find the third-highest salary from the EmpPosition table.

Q20. Write a query to display the first and the last record from the
EmployeeInfo table.

Q21. Write a query to retrieve Departments who have less than 2 employees
working in it.

Q22. Write a query to retrieve EmpPostion along with total salaries paid for each
of them.

Q23. Write a query to fetch 50% records from the EmployeeInfo table.

You might also like