0

I am trying to get data from mysql database between two dates and I want to return zero value if the date isnt found in my db.so if date is found then return value else return zero. But my code returns only the valuse which found its date

My code:

select sum(coalesce(`msaref`.`amount`,0))
From  `myshop`.`msaref` 
Where `msaref`.`date` between "2020-01-01" and "2020-01-31"
Group by Date(`msaref`.`date`)
  • The result of this query is a set which is either empty or not. How you process that set depends on the API you are using, which in turn depends on the programming language you are using, neither of which you have specified. The API may deliver a boolean if there are no rows, for example.You can program around whatever the API gives you to detect an empty result set. Why exactly do you think you need zero? – user207421 Feb 18 '20 at 09:00
  • I want to detect the amount of each date ... so if one of the dates between.the two.dates wasnt found in the db.I want to get zero value in this date .. you got it? – Mahmoud Hassan Mohamed Hassan Feb 18 '20 at 10:51

0 Answers0