SQL Assignment
SQL Assignment
2. Select the names and the prices of all the products in the store.
3. Select the name of the products with a price less than or equal to
$200.
4. Select all the products with a price between $60 and $120.
/* With AND */
SELECT * FROM Products
WHERE Price >= 60 AND Price <= 120;
/* With BETWEEN */
SELECT * FROM Products
WHERE Price BETWEEN 60 AND 120;
5. Select the name and price in cents (i.e., the price must be multiplied
by 100).
/* Without AS */
SELECT Name, Price * 100 FROM Products;
/* With AS */
SELECT Name, Price * 100 AS PriceCents FROM Products;
9. Select the name and price of all products with a price larger than or
equal to $180, and sort first by price (in descending order), and then by
name (in ascending order).
SELECT Name, Price
FROM Products
WHERE Price >= 180
ORDER BY Price DESC, Name;
10. Select all the data from the products, including all the data for
each product's manufacturer.
11. Select the product name, price, and manufacturer name of all the
products.
16. Select the name of each manufacturer along with the name and
price of its most expensive product.
UPDATE Products
SET Name = 'Laser Printer'
WHERE Code = 8;
UPDATE Products
SET Price = Price - (Price * 0.1);
20. Apply a 10% discount to all products with a price larger than or
equal to $120.
UPDATE Products
SET Price = Price - (Price * 0.1)
WHERE Price >= 120;