Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
30 views

SQL Assignments 3

The document provides a set of SQL assignment questions across multiple levels of difficulty ranging from basics to advanced concepts. It includes questions on joins, aggregation, filtering, sorting, date functions and more. A total of 30 questions are provided.

Uploaded by

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

SQL Assignments 3

The document provides a set of SQL assignment questions across multiple levels of difficulty ranging from basics to advanced concepts. It includes questions on joins, aggregation, filtering, sorting, date functions and more. A total of 30 questions are provided.

Uploaded by

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

SQL ASSIGNMENTS

Basics and Intermediate


ASSINGMENT

ASSINGMENT nos - 1
Q1)SQL Query to fetch records that are present in one
table but not in another table.

Q2)SQL query to fetch all the employees who are not


working on any project.

Q3)SQL query to fetch all the Employees from


EmployeeDetails who joined in the Year 2020.

Q4)Fetch all employees from EmployeeDetails who


have a salary record in EmployeeSalary.

Q5)Write an SQL query to fetch a project-wise count of


employees.

Q6)Fetch employee names and salaries even if the


salary value is not present for the employee.

Q7)Write an SQL query to fetch all the Employees who


are also managers.
Q8)Write an SQL query to fetch duplicate records from
EmployeeDetails.

Q9)Write an SQL query to fetch only odd rows from the


table.

Q10)Write a query to find the 3rd highest salary from a


table without top or limit keyword.

ASSINGMENT nos - 2
Ques.1. Write an SQL query to fetch the EmpId and FullName of
all the employees working under the Manager with id – ‘986’.

Ques.2. Write an SQL query to fetch the different projects


available from the EmployeeSalary table.

Ques.3. Write an SQL query to fetch the count of employees


working in project ‘P1’.

Ques.4. Write an SQL query to find the maximum, minimum, and


average salary of the employees.

Ques.5. Write an SQL query to find the employee id whose salary


lies in the range of 9000 and 15000.
Ques.6. Write an SQL query to fetch those employees who live in
Toronto and work under the manager with ManagerId – 321.

Ques.7. Write an SQL query to fetch all the employees who either
live in California or work under a manager with ManagerId – 321.

Ques.8. Write an SQL query to fetch all those employees who


work on Projects other than P1.

Ques.9. Write an SQL query to display the total salary of each


employee adding the Salary with Variable value.

Ques.10. Write an SQL query to fetch the employees whose name


begins with any two characters, followed by a text “hn” and ends
with any sequence of characters.

ASSINGMENT nos - 3
Ques.1 Write an SQL query to fetch all the EmpIds which are
present in either of the tables – ‘EmployeeDetails’ and
‘EmployeeSalary’.

Ques.2 Write an SQL query to fetch common records between


two tables.

Ques.3. Write an SQL query to fetch records that are present in


one table but not in another table.
Ques.4. Write an SQL query to fetch the EmpIds that are present
in both the tables – ‘EmployeeDetails’ and ‘EmployeeSalary.

Ques.5. Write an SQL query to fetch the EmpIds that are present
in EmployeeDetails but not in EmployeeSalary.

Ques.6. Write an SQL query to fetch the employee’s full names


and replace the space

Ques.7. Write an SQL query to fetch the position of a given


character(s) in a field.

Ques.8. Write an SQL query to display both the EmpId and


ManagerId together.

Ques.9. Write a query to fetch only the first name(string before


space) from the FullName column of the EmployeeDetails table.

Ques.10. Write an SQL query to uppercase the name of the


employee and lowercase the city values.

ASSINGMENT nos - 4
Ques.1. Write an SQL query to find the count of the total
occurrences of a particular character – ‘n’ in the FullName field.

Ques.2. Write an SQL query to update the employee names by


removing leading and trailing spaces.

Ques.3. Fetch all the employees who are not working on any
project.

Ques.4. Write an SQL query to fetch employee names having a


salary greater than or equal to 5000 and less than or equal to
10000.

Ques.5. Write an SQL query to find the current date-time.

Ques.6. Write an SQL query to fetch all the Employee details from
the EmployeeDetails table who joined in the Year 2020.

Ques.7. Write an SQL query to fetch all employee records from


the EmployeeDetails table who have a salary record in the
EmployeeSalary table.

Ques.8. Write an SQL query to fetch the project-wise count of


employees sorted by project’s count in descending order.

Ques.9. Write a query to fetch employee names and salary


records. Display the employee details even if the salary record is
not present for the employee.
Ques.10. Write an SQL query to join 3 tables.

Advanced ASSINGMENT
Q1)Write a query to fetch the EmpFname from the
EmployeeInfo table in the 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 a query to get the current date.

Q4)Write a query to retrieve the first four characters of


EmpLname from the EmployeeInfo table.

Q5)Write a query to fetch only the place name(string


before brackets) from the Address column of
EmployeeInfo table.

Q6)Write a query to create a new table that consists of


data and structure copied from the other table.

Q7)Write q query to find all the employees whose


salary is between 50000 to 100000.

Q8)Write a query to find the names of employees that


begin with ‘S’

Q9)Write a query to fetch top N records.


Q10)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.

Q11. Write a query find number of employees whose DOB is


between 02/05/1970 to 31/12/1975 and are grouped according to
gender

Q12. Write a query to fetch all the records from the


EmployeeInfo table ordered by EmpLname in descending order
and Department in the ascending order.

Q13. Write a query to fetch details of employees whose


EmpLname ends with an alphabet ‘A’ and contains five
alphabets.

Q14. Write a query to fetch details of all employees excluding


the employees with first names, “Sanjay” and “Sonia” from the
EmployeeInfo table.

Q15. Write a query to fetch details of employees with the


address as “DELHI(DEL)”.

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

Q17. Write a query to fetch the department-wise count of


employees sorted by department’s count in ascending order.
Q18. Write a query to calculate the even and odd records from a
table.

Q19. Write a SQL query to retrieve employee details from


EmployeeInfo table who have a date of joining in the
EmployeePosition table.

Q20. Write a query to retrieve two minimum and maximum


salaries from the EmployeePosition table.

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

Q22. Write a query to retrieve duplicate records from a table.

Q23. Write a query to retrieve the list of employees working in


the same department.

Q24. Write a query to retrieve the last 3 records from the


EmployeeInfo table.

Q25. Write a query to find the third-highest salary from the


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

Q27. Write a query to add email validation to your database

Q28. Write a query to retrieve Departments who have less than 2


employees working in it.

Q29. Write a query to retrieve EmpPostion along with total


salaries paid for each of them

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


table.

You might also like