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 trialWellington Souza
3,121 PointsWhat is wrong with my code?
"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"
I entered this but I do not understand what is wrong
select count(*) from orders where status = "shipped" and date("now");
Paul Resendez
2,990 PointsYes, Steven is correct. For visual learners, the below will work: SELECT COUNT(*) AS shipped_today FROM orders WHERE status = "shipped" AND ordered_on = DATE("NOW"); Enjoy.
2 Answers
Steven Parker
231,122 PointsYou forgot the alias, and your date comparison is incomplete.
It looks like junescano got closer, but you wouldn't use "IS
" to compare dates (just a regular "=
").
Also, if you're looking for "today" you wouldn't add that extra argument to subtract a day. That would be if they had asked for "yesterday" (which I think they do in a different challenge).
In future, always include a link to the course page to facilitate the most accurate answers.
Andrei Cioloca
Courses Plus Student 17,680 PointsSELECT COUNT (*) AS shipped_today FROM orders WHERE status = "shipped" AND ordered_on DATE("now");
junescano
1,864 Pointsjunescano
1,864 PointsI was struggling a bit too but i think it should be
SELECT COUNT (*) AS shipped_today WHERE status = "shipped" AND ordered_on IS DATE("now", "- 1 day");