I am trying to group by dates 2 different tables. However, something is going wrong as I am not able to group by dates.
I have 2 tables First "Budget" and Second "Sales Performance By Region" The Idea is to show the Budget for all the months (12 months) and each month we have data we will see the Sales for each specific month.
SELECT
BB.RG,
BB.YEAR,
DATE_FORMAT( BB.MONTH, '%M' ) AS `MONTH`,
SPR.Bookings,
SPR.`Bookings PY`,
SPR.Billing,
SPR.`Billing PY`,
SPR.`GP Amt`,
SPR.`GP Amt PY`,
SUM( BB.BUDGET ) AS BUDGET
FROM
BRANCH_BUDGET BB
LEFT JOIN Sales_Performance_Region SPR
ON BB.MONTH = SPR.MONTH
WHERE
BB.RG = 'FE'
AND SPR.RG = 'FE'
AND BB.YEAR = '2018'
GROUP BY
BB.MONTH
Above you can see the code. Instead of showing the 12 Months due to I only have data for 2 Months is showing January and February.
I hope the question makes sense. Can you guide me?