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

Brendan Whiting
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,696 Points

How do we know what date the order was shipped on?

Here is the challenge:

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

The schema gives us the date it was ordered on, and the status - either "shipped" or "placed". It doesn't tell us what date the order was shipped, just whether its status is shipped or not as of right now. So this is my attempt:

This is my attempt: SELECT COUNT(*) AS shipped_today FROM orders WHERE status = "shipped";

It says "Bummer! You're missing the DATE() function.

Where am I supposed to put the date function?

Brendan Whiting
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,696 Points

I just tried it again with this query:

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

And it passed. So I think this is an error in the challenge. They want you to query orders that were ordered today and also shipped when the instructions say they want it to be shipped today.

13 Answers

Steven Parker
Steven Parker
215,954 Points

Having a status of "shipped" is clearly not sufficient to insure it was shipped today. And if it was ordered today and the status is already "shipped", then it must have been shipped today. But that doesn't account for things that might have been shipped today but were ordered on other days!

I thought this was a bit odd myself, but I didn't report it. I figured what they meant by "shipped today" was "ordered and shipped today".

Perhaps you'd want to report it as a bug to Treehouse Support.

Marcia Haledjian
Marcia Haledjian
7,561 Points

This is the correct code:

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

Thanks for the help!

Shailesh Lakku
Shailesh Lakku
4,025 Points

I guess expected answer is this and it worked for me.

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

Dwayne Pate
Dwayne Pate
12,248 Points

Not sure if has been updated, but the question is currently poorly written for the query that is supposed to be written.

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

I had to write mine like this for it to pass.

Writing ("now") wouldn't allow me to pass.

Andrew Chalkley
Andrew Chalkley
Treehouse Guest Teacher

I believe I've updated the question a couple of days ago.

I am not sure if the question is updated, I faced the same problem right now.

I meant, it was not specified in the question that there is a field "ordered_on" that has the date of shipping. I searched the forum to find more about it and i found it here.

Once we have that information its pretty straight forward. Besides, Andrew Chalkley , I loved the course... easy, compact and informative. Great Job!

I agree this was worded oddly, especially considering the video we watched prior to the quiz.

Daniel Thor
Daniel Thor
18,041 Points

This question still hasn't been fixed. I run into issues like this far too often.

Andrew Chalkley

Yep question still broken, and unanswerable given the information provided...

David Braasch
David Braasch
1,019 Points

Yep, the question is wrong. In order to match the table structure the question would need to be something like:

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 today and shipped today. Alias it to ordered_shipped_today.

Andrew Chalkley please revise.

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

Issue for me was writing DATE("now") instead of DATE('now')