SQL Exercises5623-Students

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

CS 313- Web Development

Module on Database Management

Instruction: Write the correct SQL statement using MYSQL format.


1. Create the tables below
Table – EmployeeDetails
EmpId FullName ManagerId DateOfJoining City

121 John Snow 321 01/31/2019 Toronto

321 Walter White 986 01/30/2020 California

421 Kuldeep Rana 876 27/11/2021 New Delhi

Table – EmployeeSalary
EmpId Project Salary Variable

121 P1 8000 500

321 P2 10000 1000

421 P1 12000 0

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

3. Write an SQL query to fetch the number of all employees working in project ‘P1’.

4. Write an SQL query to find the maximum, minimum, and average salary of the
employees.

5. Write an SQL query to find the employee id whose salary lies in the range of 9000 and
15000. Display full name and date of joining.

6. Write an SQL query to fetch those employees who live in Toronto and work under the
manager with ManagerId – 321.

7. Write an SQL query to fetch all those employees who work on Projects other than P1.
Display full name and city.

8. Write an SQL query to display first 2 Records from EmployeeSalary table?


9. Write an SQL query to display the name of employees who have joined in 2021 and
salary is greater than 10000?
10. Write an SQL query to list the Employees full name and address whose name starts
with J and lives in Toronto

11. Write SQL query/s to insert the last 2 records into the EmployeeDetails table.

EmpId FullName ManagerId DateOfJoining City

121 John Snow 321 01/31/2019 Toronto

321 Walter White 986 01/30/2020 California

421 Kulee Rana 876 27/11/2021 Paris

521 William Smithfield 331 10/6/2022 New York

621 Annelies Jones 405 01/01/2023 Washington

12. Write an SQL query to remove the row from the EmployeeDetails table for Walter White

Note: You may use the phpMyAdmin to test your SQL statements. Be sure to open first your
database and specific table
Click this button to run
query

You might also like