I would like to code a loop which does the following:
For (# of times VariableA shows up in TableX)
SELECT ColumnM from TableX (nth occurance, N being stepped through in the loop), store as VariableB
SELECT ColumnN FROM TableY WHERE ColumnO = VariableB, store as VariableC
add VariableC to VariableD (running total)
Loop
Does this make any sense?