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.

Databases

Sobin Sebastian
Sobin Sebastian
5,348 Points

What did i do wrong?

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 yesterday. Alias it to shipped_yesterday.

my answers is SELECT COUNT(*) AS shipped_today FROM orders WHERE status = "shipped" AND ordered_on = DATE("now", "-1 day");

but its saying wrong can please someone help me understand what wrong am i doing here?

https://teamtreehouse.com/library/reporting-with-sql/date-and-time-functions/calculating-dates-2

Hey Sobin, I've noticed I've started to experience the same...I'm calling it "Code blindness", which I mean as you're getting like 99% of the problem but then you miss that final 1% because you've been working too much to get the other 99%. I appreciate Treehouse's community for helping with "code blindness". Just to give you my example, it took me a while to see what was the difference between your query in mine in terms of why mine wasn't working:

SELECT COUNT(*) AS shipped_yesterday
FROM orders
WHERE status = "shipped" 
AND DATE("now", "-1 day");

After I fixed my ordered_on = problem, I do still wonder if this query would also work:

SELECT COUNT(status) AS shipped_yesterday
FROM orders
WHERE status = "shipped" 
AND ordered_on = DATE("now", "-1 day");

2 Answers

Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher

The question asked you to write shipped_yesterday not shipped_today :)

Sobin Sebastian
Sobin Sebastian
5,348 Points

ops my bad thnx for the help

Yes. Go ahead. You found it. And they'll give points!!

Sorry, Sobin, my bad too!