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 trialGabriel E
8,916 PointsHow do I add the COUNT() function to this challenge?
So, here is the link to the challenge: https://teamtreehouse.com/library/reporting-with-sql/date-and-time-functions/todays-report. And here is my code: ```SELECT * FROM orders WHERE status = "shipped" AND COUNT("shipped_on") AND shipped_on = DATE("now");
The challenge says I need to add the COUNT() to it. I'm just not sure where to do this. Any ideas?
Thanks,
~ Gabriel
1 Answer
Paul Cox
12,671 PointsYou need to put the COUNT(*) in the select clause not in the where clause.
SELECT COUNT(*) shipped_today
FROM orders
WHERE status = "shipped" AND ordered_on = DATE("now")
Gabriel E
8,916 PointsThat makes sense, but I'm not sure how to compile the code. Its all become a mess.
Paul Cox
12,671 PointsYou were nearly there Gabriel. I've added a full example for you.
Gabriel E
8,916 PointsI see! Now one thing: Since there isn't a shipped_today column, where would I alias that too?
Paul Cox
12,671 PointsThe alias just gives the column in the output a name. You can use this to either change the name of an actual column from the table (e.g. rename cost to price), or to give a column that is calculated during the query (and hence doesn't have a name) a name (e.g. count(*) as shipped_today).
Gabriel E
8,916 PointsGabriel E
8,916 PointsOh, that totally makes sense. I got the right Query and passed the challenge. Thanks a lot for your help!