Louis Davidson solves a problem:
On LinkedIn a few days ago, there was a question that I found interesting about what was purported to be an interview question. The gist was “say you have a set that looks like this:
OrderId Item Quantity
------- ---- ---------
O1 A1 5
O2 A2 1
O3 A3 3
and you need to expand it to be one row based on the value in
Quantity
Admittedly, this kind of problem is fairly uncommon in the business world, though this is exactly the sort of thing that a tally table can solve, and that’s what Louis uses to solve the problem. Louis also gets brownie points for praising CROSS APPLY
along with tally tables.