Smartphone Price Check: Find the Most Affordable!:

Question:

Display the 'product_name' and 'price' of the cheapest smartphone available in our inventory. If there are multiple smartphones with the same lowest price, show them all.

Sample Input Tables:

Products Table:

product_id product_name category brand price stock_quantity discount
1 iPhone 13 Smartphone Apple 799 30 5
2 Galaxy S21 Smartphone Samsung 999 50 10
3 Pixel 5 Smartphone Google 599 25 0

Sample Output:

product_name price
Pixel 5 599

This output is just for illustrative purposes. The actual output could be different from the one you see above.

SELECT product_name, price
FROM Products
WHERE category = 'Smartphone' AND price = (
  SELECT MIN(price)
  FROM Products
  WHERE category = 'Smartphone'
)

English:

  • From: "Selecting the Data Source": The query begins by selecting data from the Products table, focusing specifically on smartphone products.
  • Where: "Filtering the Cheapest": It narrows down to products in the 'Smartphone' category and identifies the lowest price among them.
  • Subquery: "Finding Minimum Price": A subquery is used to find the minimum price of smartphones in the inventory.
  • Select: "Final Output": Finally, it displays the name and price of the smartphone(s) with the lowest price.

Hinglish:

  • From: "Selecting the Data Source": Query Products table se data select karta hai, khaaskar smartphone products par focus karta hai.
  • Where: "Filtering the Cheapest": Ye 'Smartphone' category mein products ko narrow down karta hai aur unmein se sabse kam price ko identify karta hai.
  • Subquery: "Finding Minimum Price": Ek subquery ka use karke inventory mein smartphones ka minimum price find kiya jata hai.
  • Select: "Final Output": Ant mein, sabse kam price wale smartphone(s) ka naam aur price display kiya jata hai


  Submit Answer


GIF Image