Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dynamic SQL query in a cursor
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00485420
Message ID:
00486356
Views:
18
I think you can do it as three different UPDATE statement. I don't have SQL Server at hand to work things out. The sticker will probably be Process #2 which wants a record number. But you might be able to change the schema to get a replacement.

This is a off-the-cuff attempt at process #1 but I'm not sure the math is right.
UPDATE the_table
SET cum = (
 SELECT CASE COUNT(*) 
  WHEN 1 THEN ren 
  ELSE SUM( ((1 + Cumprec) * (1 + Ren)) - 1) END
 FROM the_table t
 WHERE t.year <= the_table.year AND t.month < the_table.month )
-Mike
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform