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 trial

Databases

John Windmueller
John Windmueller
5,727 Points

SQL Date Function

Challenge Task 1 of 1

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.

Type in your command below.

Bummer! You're missing the DATE() function. Get Help Try Again

SELECT COUNT(status) AS shipped_today FROM orders WHERE status = "shipped";

So above is my command line. There is no column for shipped date and it doesn't seem like there is anywhere to put the DATE function to get the shipped date. Anyone have an idea of where to put the DATE in the command?

2 Answers

ALBERT QERIMI
ALBERT QERIMI
49,872 Points
SELECT COUNT(*) AS shipped_today FROM orders WHERE status = "shipped" AND ordered_on = DATE('now');
Steven Parker
Steven Parker
229,644 Points

I found that one confusing also. On reflection, I realized that anything that was ordered today and had a status of shipped must have been shipped today, and constructing a query for that seemed to appease the challenge.

But I still thought things ordered on other days might not have been shipped until today, and THOSE are not accounted for. I think there's room for improvement in the way the challenge is stated.

:point_right: So select items that were ordered today and have been shipped.

(or you can copy from Albert if you don't want to figure it out for yourself) :disappointed: