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 trialBuck McBuck
2,324 PointsChallenge appears to be flawed.
When attempting to answer the challenge that follows this video I typed in:
SELECT COUNT(*) AS shipped_yesterday FROM orders WHERE status = "shipped" AND DATE("now", "-1 day");
This returns an error, because you get shipped_yesterday with 149 orders shipped.
I was able to get the "correct" answer by writing:
SELECT COUNT(*) AS shipped_yesterday FROM orders WHERE status = "shipped" AND ordered_on = DATE("now", "-1 day");
This of course makes no sense, since the challenge asks for a count of the products shipped yesterday, not ordered yesterday. Any comments?
8 Answers
Steven Parker
231,269 PointsWell, the problem with the first query is that DATE("now", "-1 day")
is not a comparison expression in itself.
But you're right about the question being off. To do what is being asked, you'd really need another column like shipped_on
. For this answer, the question should be "count of the shipped products ordered yesterday".
You may want to report this to Support (see the "?" in the circle on the lower left of the page).
Buck McBuck
2,324 PointsThanks for the reply. I see what you mean about the first query. I will let support know something needs to be changed.
Scott Cook
16,877 PointsAgreed. The wording for the question is strange for the database schema given.
Ben Jakuben
Treehouse TeacherI am sorry that this specific challenge was unaddressed for so long! I have just updated this challenge to make it more clear. While teachers are always monitoring courses for problems and opportunities for improvement, we are also now having a small "Code Challenge Health" team proactively identify and fix issues like this one that aren't technically broken but could be improved.
Valentyn Halchuk
Courses Plus Student 1,184 PointsNothing changed yet...
Michelle Buckby
35,617 Points:(
Roy Perez
1,342 PointsDang, its been almost two years since this hasn't been fixed. Woa is me!
Ben Jakuben
Treehouse TeacherFor some context...despite the problems with this challenge, enough students were getting through successfully and rating it positively that it wasn't triggering some reporting we have set up. I'm working to improve that reporting, though, to give us better insights about trouble spots like this. We recognize that poorly worded or broken code challenges can be frustrating and discouraging, and our entire organization is committed to the constant monitoring, maintenance, and improvement we need to be an effective place of learning.
Stevan Lay
8,306 PointsFound this thread after running into trouble with the question. Used the SQL playground to run the syntax and gave me the answer of 14 whilst the quiz said it was incorrect. I'm guessing it is still not fixed?
Ben Jakuben
Treehouse TeacherIf you still have the code you ran, can you paste it in here for comparison? I can check it against our tests to see if anything else needs to be fixed.
Stevan Lay
8,306 PointsHi Ben, Here were my code that I ran: SELECT COUNT(ordered_on) AS shipped_yesterday FROM orders WHERE status = "shipped" AND ordered_on = DATE("now", "-1 day");
Problem has since been answered and fixed by using "count(*)" and replacing "ordered_yesterday_and_shipped".
Cheers!
KWAN yen SEE
1,697 PointsHey Stevan, try using COUNT(*) instead.
Kevin Gates
15,053 PointsThis worked for me. I believe I answered the updated question:
SELECT COUNT(*) AS ordered_yesterday_and_shipped
FROM orders
WHERE status = 'shipped'
AND ordered_on = date("now", "-1 day");
Stacy Villibord
2,017 PointsHi all, 2020 here. I wrote the code below but I am getting an error in my syntax. Can someone help. Thanks!
SELECT COUNT (*) AS "orderd_yesterday_and_shipped" FROM orders WHERE status = 'shipped' AND ordered_on = DATE("now, "-1 day");
Georgina Bartlett
6,185 PointsI had a bit of trouble with this one as well. Here's what worked for me (included comments to explain why I did what):
```/* select ALL with the alias ordered_yesterday_and_shipped
SELECT COUNT(*) AS ordered_yesterday_and_shipped
*/ from the orders table
FROM orders
*/ status column must be "shipped" AND the ordered_on must be yesterday ie "now" - 1 day
WHERE status = "shipped"
AND ordered_on = DATE("now", "-1 day");```
I got tripped up because in the video "=" wasn't used before DATE.
Hope this helps!
Jonathan Wadsworth
20,196 PointsJonathan Wadsworth
20,196 PointsI agree. This is a bug in both challenges. shipped_today and shipped_yesterday are worded incorrectly to be answered with the columns in the db. They still haven't fixed this....3 months later.