0% found this document useful (0 votes)
11 views1 page

Lab 10

The document contains 5 SQL statements that update, modify prices and delete records from the Orders and Products tables in a database based on dates and values. It also contains SELECT statements to retrieve order details and calculate totals grouped by customer.

Uploaded by

G Tugstuguldur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

Lab 10

The document contains 5 SQL statements that update, modify prices and delete records from the Orders and Products tables in a database based on dates and values. It also contains SELECT statements to retrieve order details and calculate totals grouped by customer.

Uploaded by

G Tugstuguldur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

1.

UPDATE Orders
SET ShipperID = 1
WHERE ShipperID <> 1 AND YEAR(ShippedDate) = 1998;
2. UPDATE products
SET UnitPrice = UnitPrice * 1.2
WHERE ProductID IN (
SELECT TOP 10 ProductID
FROM (
SELECT TOP 10 ProductID
FROM products
WHERE YEAR(OrderDate) = 1998 AND MONTH(OrderDate)>2
ORDER BY UnitPrice DESC
) AS ehnii10
);
3. DELETE FROM products
WHERE ProductID IN (
SELECT TOP 10 ProductID
FROM products
ORDER BY UnitPrice ASC
);
4. SELECT Orders.OrderID, OrderDate, ROUND(SUM(UnitPrice * Quantity * (1 -
Discount)), 2) AS tusiin_vne
FROM Orders
JOIN [Order Details] ON Orders.OrderID = [Order Details].OrderID
WHERE YEAR(OrderDate) = 1998 AND MONTH(OrderDate) <= 5
GROUP BY Orders.OrderID, OrderDate;

5. SELECT
o.CustomerID,
COUNT(DISTINCT p.ProductName) AS bvtegdhvni_too,
SUM(od.Quantity * p.UnitPrice * (1 - od.Discount)) AS zarsan
FROM
[negtgel_22b1num7075] o
JOIN
[negtgel_22b1num7075] od ON o.OrderID = od.OrderID
JOIN
[negtgel_22b1num7075] p ON od.ProductID = p.ProductID
GROUP BY
o.CustomerID
ORDER BY
zarsan DESC
LIMIT 10;

You might also like