tag:blogger.com,1999:blog-495177919198719500.post6350105249249477339..comments2023-12-27T20:52:29.483-08:00Comments on Microsoft Sql Server Tutorials: Calculate Running Total and Row Total in SQL ServerSuprotim Agarwalhttp://www.blogger.com/profile/08349831623922214390noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-495177919198719500.post-57420396229380137672010-11-04T10:09:25.082-07:002010-11-04T10:09:25.082-07:00Isn't it better to just use the very helpful w...Isn't it better to just use the very helpful window function row_number()??? Once you number the rows in the correct order, you can simply create a running total by a simple subquery... or even a join with order guaranteed. Just a suggestion.Unknownhttps://www.blogger.com/profile/17304515752836420756noreply@blogger.comtag:blogger.com,1999:blog-495177919198719500.post-90179741374368002332010-10-24T19:39:32.699-07:002010-10-24T19:39:32.699-07:00Thanks guys. The post has been updated with the li...Thanks guys. The post has been updated with the link!Suprotim Agarwalhttps://www.blogger.com/profile/08349831623922214390noreply@blogger.comtag:blogger.com,1999:blog-495177919198719500.post-74138830536921073572010-10-23T06:33:04.728-07:002010-10-23T06:33:04.728-07:00THIS METHOD IS NOT GUARANTEED TO GIVE YOU THE CORR...THIS METHOD IS NOT GUARANTEED TO GIVE YOU THE CORRECT ANSWER, AND IS NOT SUPPORTED BY MICROSOFT AS A VALID PROGRAMMING METHOD!!!! <br /><br />Having said that, if you read and STRICTLY ADHERE to the guidance put forth by Jeff Moden in the referenced link above there is a low (but non-zero) probability that you will get incorrect results.TheSQLGuruhttps://www.blogger.com/profile/09262245741634070658noreply@blogger.comtag:blogger.com,1999:blog-495177919198719500.post-35983073451436203282010-10-23T04:24:56.291-07:002010-10-23T04:24:56.291-07:00This method doesn't guarantee the order that t...This method doesn't guarantee the order that the update runs in, so should not be done IMO.<br /><br />The data that is returned while you do the update is arbitrary, even if there is a clustered index on the table.<br /><br />For more info, check out the article by Jeff Moden on SqlServerCentral.com<br />http://www.sqlservercentral.com/articles/Advanced+Querying/61716/Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-495177919198719500.post-731122326174012972010-10-22T08:58:34.183-07:002010-10-22T08:58:34.183-07:00Simply brilliant. I didn't think that a UPDAT...Simply brilliant. I didn't think that a UPDATE ... SET would use variables that way, but WHY NOT?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-495177919198719500.post-22480221854254592202010-10-21T07:28:20.536-07:002010-10-21T07:28:20.536-07:00Cool. So, the variables are set before the row fie...Cool. So, the variables are set before the row fields are updated?Anonymousnoreply@blogger.com