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

Posted by Alexander Kuznetsov on 10/02/27 11:45

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

If there are gaps in PK, it gets slightly more exciting:

select count(*) from #t t1 join #t t2
on t1.PK < t2.PK
and t1. Amount < t2.amount
where not exists(
select 1 from #t t3
where (t1.PK < t3.PK) and (t3.PK < t2.PK)
)

 

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

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