I would like to get data for the past 1week(7 days), with all days included. When there is no data for particular day, a zero should be returned.
This is what i have so far
"SELECT DATE(date) AS created_date, SUM(quantity) AS total_amount " +
"FROM milk_collection " +
"WHERE DATE(date) > DATE_SUB(DATE(NOW()), INTERVAL 30 DAY) " +
"GROUP BY created_date";
The problem is this query does not return zero(0) if no records for that day are found.