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.

ABRAHAM NYONI
9,692 PointsCan someone help me on this challenge on SQL,CALCULATING DATES.
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 yesterday and have the status of 'shipped'. Alias it to ordered_yesterday_and_shipped.
7 Answers

Walter Guerrero
6,842 PointsSELECT COUNT(status) AS "ordered_yesterday_and_shipped" FROM orders WHERE status = "shipped" AND ordered_on = DATE("now", "-1 day");
this worked for me. probly because of your aliashope that helped

ABRAHAM NYONI
9,692 PointsSELECT COUNT(status) AS shipped_yesterday FROM orders WHERE status = "shipped" AND ordered_on = DATE("now", "-1 day"); //This was my code.

Faisal Tariq
1,746 PointsI have the same problem. Using the same code as you but not getting any output.

Robbie Thomas
31,093 PointsWalter Guererro is right. However, when I did my code, it was like this:
SELECT COUNT(status) AS ordered_yesterday_and_shipped FROM orders WHERE status = "shipped" AND ordered_on = DATE("now", "-1 day");
And it told me it was expecting a count of 14. If you do that code on the SQL playground that goes along with the previous video, the count is 14. Also, I could be wrong about this but do these AS statements not require the use of quotation marks unless they need a string? Doesn't seem right that they want you to put ordered_yesterday_and_shipped with quotes in it.

Marcos Treviño Rodriguez
5,711 PointsI just did the same mistake by adding twice the "WHERE" =(, but when fixing it, it worked.

Judith Copeland
Full Stack JavaScript Techdegree Graduate 17,924 PointsI tried all the code above, and finally adding quotes around the alias worked for me:
SELECT COUNT(status) AS "ordered_yesterday_and_shipped" FROM orders WHERE status="shipped" AND ordered_on = DATE("now", "-1 day");

Aya khaled
Courses Plus Student 1,966 Pointsi recieve error

johnny lazo
13,431 PointsSELECT COUNT(*) AS ordered_yesterday_and_shipped FROM orders WHERE status = 'shipped' AND ordered_on = DATE("now", "-1 day");
D Elis
13,571 PointsD Elis
13,571 PointsHere is the solution: SELECT COUNT(*) AS ordered_yesterday_and_shipped FROM orders WHERE status ='shipped' AND ordered_on = DATE('now', '-1 day')