Re: Sum Accumulating Data



(sucaba.r@xxxxxxxxx) 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@xxxxxxxxxxxxx

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
.



Relevant Pages

  • Re: I upsized but these SQL statements are causing errors...
    ... I'm not too sure but according to books online they are usable here is what ... Returns the sum of all the values, or only the DISTINCT values, in the ... Returns one of two numeric or string values determined by a logical test. ... > what is the sql server equivalent sql of sum and iif? ...
    (microsoft.public.inetserver.asp.db)
  • Re: sum date time differentce
    ... I got can not sum date time format error message. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (microsoft.public.sqlserver.programming)
  • Re: Can SQL do this?
    ... do you mean SQL Server? ... I would like to sum the values and have the returned record set to ... ID Code Sum Other Sum ... Please reply to the newsgroup. ...
    (microsoft.public.data.ado)
  • Re: Can SQL do this?
    ... do you mean SQL Server? ... I would like to sum the values and have the returned record set to ... ID Code Sum Other Sum ... Please reply to the newsgroup. ...
    (microsoft.public.data.ado)
  • Re: Can SQL do this?
    ... do you mean SQL Server? ... ID Code Sum Other Sum ... Please reply to the newsgroup. ... This email account is my spam trap so I ...
    (microsoft.public.data.ado)