Databases Reporting with SQL Date and Time Functions Calculating Dates

Count the total number of orders that were ordered yesterday and have the status of 'shipped'. Alias it to ordered_yeste

Need help on what is wrong with my code.

SELECT COUNT(*) AS ordered_yesterdayy_and shipped FROM orders WHERE status = "shipped" AND ordered_on = DATE('now', "-1 day");

Thanks,

1 Answer

Balazs Pukli
Balazs Pukli
46,069 Points

You've put two typos in your code. Other than that, it was perfect.

Put ordered_yesterday_and_shipped instead of "ordered_yesterdayy_and shipped"

Solution:

SELECT COUNT(*) AS ordered_yesterday_and_shipped FROM orders WHERE status = "shipped" AND ordered_on = DATE('now', "-1 day");

Thanks