This is going to seem downright blasphemous to some data scientists, but it is what I'm being asked to do in support of a Power BI Report and some weird behavior on the part of the business.
Basically, I have a list of results from tests, and am being asked to invent a new category of results for estimated number of tests when the total number of tests is less than the recorded estimate.
I already have two recordsets- the list of real results, and the categorized list of the difference between Real and Estimate.
I'm sure I could, with a double while loop and a cursor, simply loop through the recordset and then run a while loop
But there has to be a way to do this with set operations.
Basically, what I need is something like:
Insert Into Results (Result, EndDate-1hour, category, subcategory) Select Result, Enddate-1hour, category, subcategory for records loop NumberofRecords=EstimateDelta
But even with 21 years of experience in SQL, I don't know quite how to do that.