I want to create a table [Top Stores] that has 10 most active stores in terms of quantity of product sold. Each store sells 3 products. I just need to add the quantity sold for each product to arrive at StoreSale. The problem is when there is no sale for a product, the quantity value is left blank and not 0. I try to change the blank to 0 by the isnull tests. Please point out the error in my code below:
SELECT top 10 StoreName, StoreSale = (iif (isnull(Product1), 0, Product1) + iif (isnull(Product2), 0, Product2) + iif (isnull(Product3), 0, Product3)) INTO [Top Stores]
FROM SaleTable ORDER BY StoreSale DESC;