try thisdeclare @table table( Value int, Date datetime)insert into @tableselect 12, '1-1-2006' union allselect 14, '1-2-2006' union allselect 100, '1-8-2006' union allselect 35, '1-10-2006' union allselect 50, '1-12-2006' union allselect 5, '1-15-2006'select sum(Value)from( select *, prev_value = (select top 1 Value from @table x where x.Date < t.Date order by Date desc), next_value = (select top 1 Value from @table x where x.Date > t.Date order by Date) from @table t) awhere ( Value > prev_value and Value > next_value )or next_value is null
KH