Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


What 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");

I 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");

Paul Resendez
Paul Resendez
2,990 Points

Yes, 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
Steven Parker
216,149 Points

You 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.

SELECT COUNT (*) AS shipped_today FROM orders WHERE status = "shipped" AND ordered_on DATE("now");