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

Brendan Whiting
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 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,738 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
231,261 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,562 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!

Dwayne Pate
Dwayne Pate
12,249 Points

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

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

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')