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

Posted by Erland Sommarskog on 10/02/34 11:45

(sucaba.r@gmail.com) writes:
> From looking at the table, the system ran for three days before it was
> reset (rows 1-3). It then ran for 4 days (rows 4-7) for a total of 7
> (not 5 as I indicated above). So I'd need to capture 7 as the total.

To be perfectly honest, you will never get any help with your queries,
if you don't have a grip of the business requirements.

Here is a query based on Tom's table, but it returns 6 and not 7, because
the first row is not counted:

select count (*)
from @t a
JOIN @t b ON a.PK = b.PK + 1
WHERE a.Amount > b.Amount




--
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

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