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

sql

The document contains a series of SQL queries for retrieving product information from a database. Queries include selecting product names and prices, filtering products by price range, calculating averages, counting products, and joining with manufacturer data. It also includes a query to find the cheapest product in the store.

Uploaded by

rakhmatovaa
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)
10 views1 page

sql

The document contains a series of SQL queries for retrieving product information from a database. Queries include selecting product names and prices, filtering products by price range, calculating averages, counting products, and joining with manufacturer data. It also includes a query to find the cheapest product in the store.

Uploaded by

rakhmatovaa
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.

Select the names of all the products in the store


SELECT Name FROM Products;

-- 2. Select the names and the prices of all the products in the store.
SELECT Name, Price FROM Products;

-- 3. Select the name of the products with a price less than or equal to $200.
SELECT Name FROM Products WHERE Price <= 200;

-- 4. Select all the products with a price between $60 and $120.
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).
SELECT Name, Price * 100 AS PriceInCents FROM Products;

-- 6. Compute the average price of all the products.


SELECT AVG(Price) AS AveragePrice FROM Products;

-- 7. Compute the average price of all products with manufacturer code equal to 2.
SELECT AVG(Price) AS AveragePrice FROM Products WHERE Manufacturer = 2;

-- 8. Compute the number of products with a price larger than or equal to $180.
SELECT COUNT(*) AS NumberOfProducts FROM Products WHERE Price >= 180;

-- 9. Select the product name, price, and manufacturer name of all the products.
SELECT Products.Name, Products.Price, Manufacturers.Name AS ManufacturerName
FROM Products
JOIN Manufacturers ON Products.Manufacturer = Manufacturers.Code;

-- 10. Select the name and price of the cheapest product.


SELECT Name, Price FROM Products ORDER BY Price ASC LIMIT 1;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy