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

Namazbek Bekarysuly
Namazbek Bekarysuly
882 Points

What is wrong?

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

Namazbek Bekarysuly
Namazbek Bekarysuly
882 Points

SELECT COUNT(id) FROM orders WHERE status = "shipped" AND DATE("now"); this did not work too

1 Answer

Eric Butler
Eric Butler
33,475 Points

2 hints, because your first one is very close: You want to count all records (so count "id"s, which are always distinct); and the date function, if given no parameters, defaults to today, so you don't actually need any parameter in there. Good luck!