Querying with SQL Coding Practice - 2

 Consider an e-commerce company like Amazon that holds the data of a wide variety of products. On such platforms, users often search for products by appling multiple conditions at once.

For example, user could ask for shoes from Puma brand, that have ratings greater than 4.0 (and price less than 5000).

With logical operators, we can perform queries based on multiple conditions.

Similar to the e-commerce scenario, we have a database that contains a range of products with details like the name of the product, category it belongs to, price, brand and rating. Help the user get the desired products by writing SQL queries satisfying user requirements.

Note: Expected output format for all the queries, unless specified.

namecategorypricebrandrating
Black ShirtClothing900Puma4.8
---------------

1. Get all the details of products that belong to "Clothing" category and price less than 700.

2. Get all the details of products that belong to "Denim" brand with rating greater than 4.

3. Get all the best-rated products with price less than or equal to 1000.

Note: Assume that the products with rating greater than 4.0 as best rated products.

4. Get all the products from the product table whose 


rating is above 3.6 and

price is less than 1000 and

Belongs to "Puma" brand

5. Get all the products from "Puma", "Denim" or "Nike" brands.

6. Get all the details of products whose


brand is "Redmi" with rating greater than 4 or

products that belong to "OnePlus" brand.

7. Get only cakes from "Cadbury" and "Britannia" brands that have rating greater than 4.0.

Note: Consider the products that have "Cake" innameas cakes.

8. Get all the details of the products from the product table whose


brand is "Puma" and rating greater than 3.5 or

brand is "Denim" and rating greater than 4.0

9. Get all the shirts available in "Puma" , "Nike" or "Levi's" brands, excluding the black colour shirts.


Note: 

You can assume that:

1. Products containing “Shirt” in name are considered as shirts.

2. Black colour shirts contain "Black" in their names.

namecategorypricebrandrating
Blue ShirtClothing750Denim3.8
Blue JeansClothing800Puma3.6
Black JeansClothing750Denim4.5
Blue ShirtClothing1000Puma4.3
Chocolate CakeFood25Britannia3.7
Strawberry CakeFood60Cadbury4.1
Chocolate CakeFood60Cadbury2.5
Strawberry CakeFood10Britannia4.6
Smart WatchGadgets17000Apple4.9
Smart CamGadgets2600Realme4.7
Smart TVGadgets40000Sony4
Bourbon SmallFood10Britannia3.9
Bourbon SpecialFood15Britannia4.6
Bourbon With Extra CookiesFood30Britannia4.4
White ShirtClothing700Denim4.3
Black ShirtClothing600Puma4.8
Black T-ShirtClothing600Roadster4.2
White T-ShirtClothing700Levi's4
Blue T-ShirtClothing600Nike4.7
Realme Smart BandGadgets3000Realme4.6
Raw CashewFood370Absa3.9
Cashew NutsFood550Upcrop4.3
Chocolate CashewFood670Urban Platter3.5
Potato Chips India’s Magic MasalaFood42Lay's4.4
Banana ChipsFood550Calicut Kerala4.3
Potato Chips Cream & onionFood63Lay's4.5
Potato Chips Classic SaltedFood45Lay's4
Harry Potter and the Philosopher's StoneNovel2224.7
Harry Potter and the Chamber of SecretsNovel3434.4
Harry Potter and the Prisoner of AzkabanNovel2844.2
Harry Potter and the Goblet of FireNovel4314.6
OnePlus 6TSmartphone32990OnePlus4.5
Redmi K20Smartphone24999Redmi4.1

Post a Comment

Please Select Embedded Mode To Show The Comment System.*

Previous Post Next Post

Contact Form