I have daily sales data where there are sometimes no sales for certain stores, NULLs on certain days are causing me problems and I would like to see a row with 0. I am wondering how to achieve this, is it possible with a full outer join where I maybe look at the distinct days and combine with the distinct list of shops for example?
Below is a simple example, I would like to see another row for 02/01/26 for Shop 1 with 0 sales:
SELECT d.SaleDate,
s.Shop,
COALESCE(x.Sales, 0) AS SalesAmount
FROM (SELECT DISTINCT SaleDate FROM Sales) d
CROSS JOIN (SELECT DISTINCT Shop FROM Sales) s
LEFT JOIN Sales x
ON x.SaleDate = d.SaleDate
AND x.Shop = s.Shop
ORDER BY d.SaleDate, s.Shop;