Select All From Department
Select All From Department
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’.
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’
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.
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.
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.
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.