Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialPatrick Sullivan
Python Development Techdegree Student 6,083 PointsSQL Challenge using DATE() correctly.
In an ecommerce database there's an orders table with the columns id, product_id, user_id, address_id, ordered_on, status and cost. Count the total number of orders that have the status of shipped today. Alias it to shipped_today.
SELECT COUNT(status) FROM orders WHERE status = "shipped" AND DATE("now");
I'm not quite sure where my code is wrong, the count I am getting seems to be all things no matter the WHERE. What's the correct solution?
1 Answer
Steven Parker
231,261 PointsYou didn't link to the challenge, so I can't check to be certain. But I do see a couple of issues:
- You forgot the instruction that says: "Alias it to shipped_today."
- "
DATE("now")
" isn't a comparison. You probably meant: "ordered_on = DATE("now")
"
Patrick Sullivan
Python Development Techdegree Student 6,083 PointsPatrick Sullivan
Python Development Techdegree Student 6,083 PointsLooks like putting "ordered_on" = DATE("now") was the correct thing. I think the issue I was having was, when it says count total number of orders that have the status of shipped today I didn't assume that things that were ordered today were also shipped today. Thank you!