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 trialBrendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsHow 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?
13 Answers
Steven Parker
231,261 PointsHaving 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
7,562 PointsThis is the correct code:
SELECT COUNT(*) AS shipped_today FROM orders WHERE status = "shipped" AND ordered_on = DATE("now");
Orchid Li
2,024 PointsThanks for the help!
Dwayne Pate
12,249 PointsNot sure if has been updated, but the question is currently poorly written for the query that is supposed to be written.
Shailesh Lakku
4,025 PointsI 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")
Anton Cerda
Front End Web Development Techdegree Student 6,795 PointsSELECT 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.
Sobin Sebastian
5,348 PointsAndrew Chalkley is there a bug in this question ?
Andrew Chalkley
Treehouse Guest TeacherI believe I've updated the question a couple of days ago.
Krishna Pratap Chouhan
15,203 PointsI am not sure if the question is updated, I faced the same problem right now.
Andrew Chalkley
Treehouse Guest TeacherWhat is the SQL you're using Krishna Pratap Chouhan?
Krishna Pratap Chouhan
15,203 PointsI 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!
NiKole Maxwell
11,083 PointsI agree this was worded oddly, especially considering the video we watched prior to the quiz.
Daniel Thor
18,041 PointsThis question still hasn't been fixed. I run into issues like this far too often.
Brian Steinke
1,792 PointsYep question still broken, and unanswerable given the information provided...
David Braasch
1,019 PointsYep, 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.
mohammed ahmed
1,539 Pointsselect count(*) as shipped_today from orders where status = 'shipped' and ordered_on= date('now');
Anshul Karia
1,221 PointsIssue for me was writing DATE("now") instead of DATE('now')
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsBrendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsI 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.