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!
You work for an e-commerce platform that runs various promotional events. Each promotion has a start date and an end date, and your task is to list all active promotions—those where the current date is within the valid promotion period.
Write an SQL query to fetch all active promotions from the promotion_events
table.
- Select the following columns:
id
(Promotion ID)name
(Promotion Name)start_date
(Start Date)end_date
(End Date)price_reduction
(Discount Amount)
- Only include promotions where the current date falls within the
start_date
andend_date
. - Order the results by
start_date
in ascending order.
Here’s an example of the promotion_events
table (The actual data can be found in init.sql
):
id | name | start_date | end_date | price_reduction |
---|---|---|---|---|
1 | Spring Sale | 2025-03-20 00:00:00 | 2025-04-05 23:59:59 | 20 |
2 | Summer Deals | 2025-06-01 00:00:00 | 2025-06-15 23:59:59 | 15 |
3 | Winter Blast | 2025-12-01 00:00:00 | 2025-12-31 23:59:59 | 25 |
You can view the database ERD here:
Write a query to return only the active promotions.
- 📌 Read the Setup Instructions to get everything up and running.
- 📝 Run your query.
- 💡 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
You only need to set up the database once for all challenges in Scenario A (see challenge name). Each scenario uses slightly different data, tailored to match the specific challenge requirements.