0% found this document useful (0 votes)
10 views4 pages

Select All From Department

The document contains two SQL assignments with a series of queries to be executed on two sets of tables: EmployeeInfo and EmployeePosition for Assignment-1, and emp, proj, dept, and workson for Assignment-2. Each assignment includes various tasks such as fetching employee details, calculating salaries, and filtering records based on specific criteria. The queries cover a wide range of SQL functionalities including joins, aggregations, and data manipulations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views4 pages

Select All From Department

The document contains two SQL assignments with a series of queries to be executed on two sets of tables: EmployeeInfo and EmployeePosition for Assignment-1, and emp, proj, dept, and workson for Assignment-2. Each assignment includes various tasks such as fetching employee details, calculating salaries, and filtering records based on specific criteria. The queries cover a wide range of SQL functionalities including joins, aggregations, and data manipulations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

SQL Basic Assignment-1

Use the below Tables for Assignment-1


EmployeeInfo Table:
EmpID EmpFname EmpLname Department Project Address DOB Gender
1 Sanjay Mehra HR P1 Hyderabad(HYD) 01/12/1976 M
2 Ananya Mishra Admin P2 Delhi(DEL) 02/05/1968 F
3 Rohan Diwan Account P3 Mumbai(BOM) 01/01/1980 M
4 Sonia Kulkarni HR P1 Hyderabad(HYD) 02/05/1992 F
5 Ankit Kapoor Admin P2 Delhi(DEL) 03/07/1994 M

EmployeePosition Table:
EmpID EmpPosition DateOfJoining Salary
1 Manager 01/05/2024 500000
2 Executive 02/05/2024 75000
3 Manager 01/05/2024 90000
2 Lead 02/05/2024 85000
1 Executive 01/05/2024 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 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 which 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.

SQL Assignment-2
Some Practice Database SQL Questions WorksOn Database:
Tables and It columsn will be : use the below tables for Assignment-2
emp (eno, ename, bdate, title, salary, dno)
proj (pno, pname, budget, dno)
dept (dno, dname, mgreno)
workson (eno, pno, resp, hours)

Questions:
1) Write an SQL query that returns the project number and name for projects with a budget greater
than $100,000.
2) Write an SQL query that returns all works on records where hours worked is less than 10 and the
responsibility is 'Manager'.
3) Write an SQL query that returns the employees (number and name only) who have a title of 'EE' or
'SA' and make more than $35,000.
4) Write an SQL query that returns the employees (name only) in department 'D1' ordered by decreasing
salary.
5) Write an SQL query that returns the departments (all fields) ordered by ascending department name.
6) Write an SQL query that returns the employee name, department name, and employee title.
7) Write an SQL query that returns the project name, hours worked, and project number for all works on
records where hours > 10.
8) Write an SQL query that returns the project name, department name, and budget for all projects with
a budget < $50,000.
9) Write an SQL query that returns the employee numbers and salaries of all employees in the
'Consulting' department ordered by descending salary.
10) Write an SQL query that returns the employee name, project name, employee title, and hours for all
works on records.

You might also like