You are here: Re: Sum Accumulating Data « MsSQL Server « IT news, forums, messages
Re: Sum Accumulating Data

Posted by Erland Sommarskog on 04/15/06 00:42

(sucaba.r@gmail.com) writes:
> I've got a table that contains a column of accumulating uptime data
> that looks similar to this:
>
> 239.13
> 239.21
> 239.30
> 239.38
> 239.46
> 239.55
> 0.35
> 0.44
> 0.53
> 0.60
> 0.68
> 0.78
> 0.85
> 0.93
>
> I need to SUM the data up the point where the data gets reset (the next
> row is less than the preceeding row). Then I start the SUM again until
> data gets reset.

You want something like this:

239,13
239,21 478,34
239,3 717,64
239,38 957,02
239,46 1196,48
239,55 1436,03
0,35 0,35
0,44 0,79
0,53 1,32
0,6 1,92
0,68 2,6
0,78 3,38
0,85 4,23
0,93 5,16

If the values are accumulated sums, it seems funny to sum them again.

Since I don't want to solve the wrong problem, I suggest that you post

o The CREATE TABLE statement for your table (possibly simplified).
o INSERT statements with sample data.
o The desired output given the sample.

That is likely to give you a tested solution. Whereas from what you
have posted now, at best could give you guesses.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация