Skip to content

veryacademy/SQL-Challenge-0004-Scenario-A

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Master SQL with Our Course!

Want to level up your SQL skills? Our SQL Fundamentals Course covers everything from basics to advanced queries.

🔥 Join the Udemy Course today and start learning!
📌 Click here to enroll now!


🚀 Challenge: Get All Products That Belong to a Specific Category

📚 Introduction

You work for an e-commerce platform that organizes products into different categories. Your task is to fetch all products that belong to a specific category, including the category details.


🎯 Challenge Specification

Write an SQL query to return all products under a specific category from the category and products tables.

✅ Requirements:

  • Select the following columns:
    • category_id (Category ID)
    • category_name (Category Name)
    • product_id (Product ID)
    • product_name (Product Name)
    • price (Product Price)
  • The query must return only products that belong to a given category (select category by name not by id).
  • Order the results by product_name in ascending order.

🛡️ Sample Data

Here’s an example of the category and products tables (The actual data can be found in init.sql):

category Table

id name is_active
1 Electronics true
2 Clothing true
3 Books false

products Table

id category_id name price is_active
1 1 Laptop 999.99 true
2 1 Smartphone 699.99 true
3 2 T-Shirt 19.99 true
4 3 Novel 12.99 false

🔗 Entity-Relationship Diagram (ERD)

You can view the database ERD here:

🔗 Lucidchart ERD


🤔 Try It Yourself

Write a query to return only the products for a given category.


🔗 Next Steps

  1. 📌 Read the Setup Instructions to get everything up and running.
  2. 📝 Run your query.
  3. 💡 Need help? Check out the solutions.sql file.

Watch the first Challenge if you need more help getting the code started.
🔗 Link to first Challenge 001


📌 Don't Forget

You only need to set up the database once for all challenges in Scenario A. Each scenario uses slightly different data, tailored to match the specific challenge requirements.

About

Get All Products That Belong to a Specific Category.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors