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

Lab Task 05

Uploaded by

kzkhtxydm6
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)
14 views

Lab Task 05

Uploaded by

kzkhtxydm6
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/ 6

Department of Creative Technology

Subject:
Database Systems Lab

Submitted to:
Mr. Wasim Wahid

Name: Muhammad Asad Ullah Turab


Reg No: 221844
Section: BSSE-IV-B
Date: 11-Mar-24
SQL Task 01

 SELECT with WHERE clause (AND, OR):


Query:
SELECT * FROM Products WHERE (Price BETWEEN 50 AND 100) OR (Category = 'Electronics');
Output:

 SELECT with SUM and GROUP BY:


Query:
SELECT p.Category, SUM(s.SaleAmount) AS TotalSales
FROM Sales s JOIN Products p ON s.ProductID = p.ProductID
GROUP BY p.Category;
Output:
 SELECT with AVG and WHERE clause:
Query:
SELECT AVG(Age) AS AverageAge FROM Users WHERE City = 'New York';
Output:

 SELECT with MIN and MAX:


Query:
SELECT
MIN(MinTemperature) AS MinTemperature,
MAX(MaxTemperature) AS MaxTemperature
FROM Weather;
Output:

 SELECT with ORDER BY:


Query:
SELECT *
FROM Products
ORDER BY Price DESC
LIMIT 10;
Output:

SQL Task 02
 DELETE with WHERE clause:
Query:
DELETE FROM Orders
WHERE OrderDate < '2023-01-01';

Output:

Before After
 UPDATE with WHERE clause:
Query:
UPDATE Products
SET Price = Price * 1.10
WHERE Category = 'Clothing';
Output:

 SELECT with LIMIT:


Query:
SELECT *
FROM Customers
ORDER BY CustomerName
LIMIT 5;
Output:
 SELECT with LIKE:
Query:
SELECT *
FROM Products
WHERE ProductName LIKE '%phone%';
Output:

 SELECT with JOIN and WHERE clause:


Query:
SELECT
o.OrderID, o.OrderDate, o.OrderAmount, c.CustomerName, c.Email
FROM
Orders o
JOIN
Customers c ON o.CustomerID = c.CustomerID
WHERE
o.OrderAmount > 500;
Output:

You might also like