Databases Reporting with SQL Date and Time Functions Today's Report

Kevin Haller
Kevin Haller
5,940 Points

Mistake in task definition. The query wants to find out all orders, which were shipped today.

SELECT COUNT(*) AS "shipped_today" FROM orders WHERE shipped = DATE("now");

does yield a result of 0.

So <shipped> needs to have the value of "shipped" and we need to find the column with the numeric value of DATE("now"). The only column, that would come into consideration is <ordered_on>.

SELECT COUNT(*) AS "shipped_today" FROM orders WHERE ordered_on = DATE("now") AND status = "shipped";

yields the correct answer of 13 however, now we don't have all the orders that have been marked as "shipped" today, but all orders that have been marked as "ordered" today, which is a difference.

Am I right or do I miss something?

Patrik Horváth
Patrik Horváth
11,081 Points

check question again : In an ecommerce database there's an orders table with the columns id, product_id, user_id, address_id, ordered_on, status and cost.

it clearly tells you with collums you have in table and Logic tell you shipped should be true or false or text because if you have ordered_on collumn in table =\

but who know every one have other thinking

1 Answer

Steven Parker
Steven Parker
203,226 Points

I also found the language of the instructions a bit confusing. I reworded it slightly for myself to say, "Count the total number of orders that have the status of shipped that were ordered today."

You might want to report this as a bug to Support.