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

Assignment

The document contains a series of SQL queries designed to perform various operations on employee and student databases. It includes queries to filter employees by salary, name patterns, and manager IDs, as well as to create a new table and update existing records. Additionally, it demonstrates how to delete records based on specific conditions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

Assignment

The document contains a series of SQL queries designed to perform various operations on employee and student databases. It includes queries to filter employees by salary, name patterns, and manager IDs, as well as to create a new table and update existing records. Additionally, it demonstrates how to delete records based on specific conditions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

ASSIGNMENT

Q1 Write q query to find all the employees whose salary is between 50000
to 100000.
SELECT * FROM Employee
WHERE Salary BETWEEN '50000'
AND '100000';
Q2 Write a query to find the names of employees that begin with ‘S.
SELECT * FROM Employee
WHERE EmpFname LIKE 'S%';
Q3 Write a query to fetch all the records from the EmployeeInfo table
ordered
by EmpLname in descending order and Department in the ascending
order

SELECT * FROM Employee ORDER BY EmpFname desc, Department


asc;

Q4 Write a query to fetch details of employees whose EmpLname ends


with an alphabet ‘A’
and contains five alphabets.
SELECT * FROM Employee WHERE EmpLname LIKE '____a';
Q5 Write a query to fetch details of all employees excluding the
employees with first names, “Sanjay” and “Sonia” from the EmployeeInfo
table.
SELECT * FROM Employee WHERE EmpFname NOT IN
('Sanjay','Sonia');
Q6 Write an SQL query to fetch the EmpId and FullName of all the
employees working under Manager with id – ‘986’.
SELECT EmpId, FullName
FROM Employee
WHERE ManagerId = 986;
Q7 Write an SQL query to fetch those employees who live in delhi and
work under manager with ManagerId – 321.
SELECT EmpId, City, ManagerId
FROM Employee
WHERE City='delhi' AND ManagerId=321;
Q8 Write an SQL query to fetch all the employees who either live in delhi or
work under a manager with ManagerId – 321 SELECT EmpId, City,
ManagerId
FROM Employee
WHERE City='delhi' OR ManagerId=321;
Q9 Write an SQL query to fetch all those employees who work on Project
other than
SELECT EmpId
FROM Employee
WHERE NOT Project='P1';
oR
SELECT EmpId
FROM Employee
WHERE Project <> 'P1'

Q10 Display those rows from the table Students where the value of the field
ROLL_NO is either 20 or 21 or 23.
SELECT * FROM Students WHERE ROLL_NO IN (20,21,23);
Q11 Create a table called "Persons" that contains five columns: PersonID,
LastName, FirstName, Address, and City.
CREATE TABLE Persons (
PersonID int,
LastName varchar(25),
FirstName varchar(25),
Address varchar(25),
City varchar(25)
);
Q12 To select the first name of all the
Employees the query would be like:
 SELECT first_name FROM
Employee;
Q13 To List all customers from table employee
SELECT *
FROM Employee;
Q14 Delete all products with unit price higher than rs 50.
DELETE FROM employee
WHERE UnitPrice > 50;
Q15 Update the city to mumbai for supplier britannia ,Ltd.
UPDATE Supplier
SET City = 'mumbai'
WHERE Name = 'britannia, Ltd.'

You might also like