I writes a query to get the result like sum of the amount for each product group by date.
When getting the output some products does not have corresponding amount for the date.that dates are not listing in the output So i need every date to display and if amount is there it need to show the amount otherwise 0.
I tried using IFNULL and COALESCE but getting same output.
My OUTPUT
date amount
2019-05-16 499
2019-05-17 1998
2019-05-18 999
2019-05-19 999
Needed output should look like this
date amount
2019-05-16 499
2019-05-17 1998
2019-05-18 999
2019-05-19 999
2019-05-20 0
query for getting data from mysql
$query = "select date, SUM(amount) as amount from product_details where date between '2019-05-16 00:00:00' and '2019-05-20 23:59:59' and prodid = 1 group by date";
Is there any way to make appear the date which does not have amount?