I’m struggling with an interview question I had recently. 3 dimension tables (Product, Store and Date) and 1 fact table (Sales). The question asked for a T-SQL solution that will return the count of products not sold, per store, per day over the past month.
That ship has sailed…opportunity has passed, but I’ve since spent significant time trying to back into a solution, to no avail, and would like to close the loop. Any guidance is greatly appreciated.
Typically “what didn’t happen” is answered using a coverage table. This may have been a “trick” question to see if you knew about using a Factless Fact table do to negative analysis.
This table would be one row / day / product / store, identifying all the products that were available in a particular store on a particular day. You’d then use that table and do a set subtraction of the products that sold from the sales fact, to get the products that didn’t sell.
It doesn’t make sense necessarily to join to product dim because not all products may be sold in all stores. It was likely just a question to see if you could build the necessary SQL, but I think it’s a poor question in general.