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!

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 trial

Databases Reporting with SQL Date and Time Functions Today's Report

Lyola Rowe
Lyola Rowe
3,803 Points

Need help with this query

I'm typing in this query - what am I doing wrong?

select count(*) from orders where status="shipped" and ordered_on=date(now) as shipped_today;

2 Answers

You have to put the 'now' in quotes and place 'as shipped_today' in between count(*) and from.

Lyola Rowe
Lyola Rowe
3,803 Points

Thank you! What about this challenge? 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 were ordered yesterday and have the status of 'shipped'. Alias it to ordered_yesterday_and_shipped.

I'm posting this and it's not working: select count(*) as ordered_yesterday_and_shipped from orders where status="shipped" and ordered_on=date("now"; "-1 day");

Replace the semicolon in your date function with a comma.