0% found this document useful (0 votes)
0 views

Write an SQL Query

The document contains a series of SQL query tasks across multiple sections, focusing on retrieving, updating, and analyzing data from various tables such as Products, Cars, Employees, Students, and Watches. Each section includes specific queries to filter, count, and manipulate data based on given conditions. Additionally, there are queries to find outputs based on certain criteria, showcasing practical SQL applications.

Uploaded by

kj455026
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)
0 views

Write an SQL Query

The document contains a series of SQL query tasks across multiple sections, focusing on retrieving, updating, and analyzing data from various tables such as Products, Cars, Employees, Students, and Watches. Each section includes specific queries to filter, count, and manipulate data based on given conditions. Additionally, there are queries to find outputs based on certain criteria, showcasing practical SQL applications.

Uploaded by

kj455026
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

1. Write an SQL query to list all order items associated with product ID 3.

2. Write an SQL query to find all products that are not monitors.
3. Write an SQL query to find all products that are either keyboards or mouse.
4. Write an SQL query to find all products whose names end with the letter 'r'.
5. Write an SQL query to find all orders where the total price is greater than 100.
Find the out of the following
6. SELECT * FROM Products WHERE Price BETWEEN 20 AND 200;
7. SELECT COUNT(*) AS TotalProducts FROM Products;
SQL 2
1. Write a query to list the cars whose make starts with 'B'.
2. Write a query to find all cars from the year 2020 or newer.
3. Write a query to list all cars that are either a 'Toyota' or a 'Honda'.
4. Write a query to update the sale price of the sale with SaleID = 1 to $24,000.
5. Write a query to count the number of sales for each car make.
******* Find the output of following******
6. SELECT c.Make, AVG(s.SalePrice) AS AverageSalePrice FROM Cars c, Sales s WHERE c.CarID =
s.CarID GROUP BY c.Make;
7. SELECT Make, Model, Year, Price FROM Cars WHERE Model LIKE '%Class%’;

SQL 3

1. Write a query to retrieve all employees from the Employees table.


2. Write a query to find employees who joined before 1 January 2021.
3. Write a query to retrieve the list projects managed by a EmployeeID =1
4. Write a query to change the department of the employee with EmployeeID = 2 to 'Marketing.
5. Write a query to List all employees whose first name has exactly four characters.
*** Find the Output of the following***
6. SELECT *FROM Employees WHERE JoinDate > '2020-01-01' AND Department = 'IT';
7. SELECT Department, COUNT(*) AS NumEmployees FROM Employees GROUP BY Department;
SQL 4

1. Write a query to list the names of students whose last name starts with 'S'.
2. Write a query to order students by last name in descending order.
3. Write a query to delete a student whose student ID is 3.
4. Write a query to select students older than 21.
5. Write a query to select students aged between 20 and 22.
****Find the output of the following*****
6. SELECT * FROM Student WHERE LastName NOT LIKE '%o%';
7. UPDATE Student SET Age = 23 WHERE FirstName = 'Emma' AND LastName = 'Watson';

SQL 5
1. To display all the details of those watches whose name ends with ‘Time’
2. To display watch’s name and price of those watches which have price range in between 5000-15000.
3. To display total quantity in store of Unisex type watches.
4. To display watch name and their quantity sold in first quarter.
5. Write a query to display the maximum price and minimum quantity in store from the Watches table.
****Find the output of the following*****
6. SELECT quarter, sum(qty_sold) FROM sale GROUP BY quarter;
7. SELECT watch_name, qty_store, SUM(qty_sold), qty_store-SUM(qty_sold) AS STOCK FROM watches w, sale s
WHERE w.watchid=s.watchid GROUP BY s.watchid;

You might also like