Querying with SQL Coding Practice - 3

 

With this practice set, you'll get thorough with:

  • How to filter based on multiple conditions and how to apply filters within a specified range.
  • Sort and limit the entries of the output making it easier to fetch meaningful insights.

Here, the database consists of a

product
table that stores the
name
,
category
,
price
,
rating
and
brand
of the products. Let's go!

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

namecategorypricebrandrating
Black ShirtClothing900Puma4.8
---------------
1.
Get all the products from "Roadster", "Levi's" or "Puma" brands.
Note: Output must contain rows in the ascending order ofpriceof the product.

2.
Get all the products that are in the price range of 750 to 1000.

Note: 
-  Include the products with price 750 and 1000 as well.
-  Output must contain rows in the ascending order ofpriceof the product. If two products are of same price, then sort bynamein the alphabetical order.

3.
User wants to purchase clothes that have high-rating and low-cost.
Get the products from the "Clothing" category as per the user requirements, i.e.,

Keep highly-rated products at the top
Sort the price from low to high


4.
List all the brands available in the ascending order.
Note: Output must contain rows in the alphabetical order of name of thebrand

Expected Output Format:

brand
...


5.
User has checked first 10 products keeping highly-rated products at the top. Help the user check the details of next 10 products.

Note: If two products have the same rating, then sort bynamein the alphabetical order.

6.
Get all the details of the products from producttable whose

brand is Puma or Denim and
rating greater than 4
Get products with lowest price first

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