I have a result table.
I want to union this result table with list of dates .I wanted to know how to find the lists of date between from date and to date for union operation.
for example,if from date is '2022-06-10' and to date is '2022-06-17'.I wanted to find the list of date between from and to .If there is no data in the result for specific date set the total to 0.My expected output.
My current result query
SELECT sum(q.amount) as total,date(q.created_date) as date FROM quotation q
where q.created_date <= '2022-06-10'
and q.created_date >= '2022-06-17'
group by DATE_FORMAT(q.created_date, "%d/%m/%Y")
union
(select 0 as total,date(DATE_SUB(CURDATE(), INTERVAL 1 DAY) ))
order by DATE_FORMAT(date,"%d/%m/%Y");
The result