• stephen.poulitsis (8/8/2012)


    Dear Gabriel

    Your article is outstanding!

    I would like to ask how the code would need to be altered if instead of one security, the table contained data for many securities.

    This is similar to the the bank balance problem that Jeff uses in his article, where he calculates the running total for each account (in this case the SMA for each security in the EMA problem).

    Can you help?

    Kind Regards

    Stephen Poulitsis

    Hi Stephen,

    Because of the iterative nature of the update statement in that each row depends on the row prior to it, there's not an apparent way that comes to mind on how to do this with multiple securities and still keep it all as one update statement.

    If it's possible that you can access SQL Server 2012 for this business requirement, I would implore you to learn about the new features they have added to the windowing functions using ROWS/RANGE functionality should theoretically provide a better way to accomplish this. I haven't done any work with securities in a while however, so I cannot confirm it.