Archives of the TeradataForum
Message Posted: Tue, 01 Dec 2009 @ 20:37:58 GMT
Subj: | | Re: Incrementing count within a group of records |
|
From: | | Ulrich |
Hi David,
it should be possible if you can use a derived table.
select t.*.sum(week_change_id) over (order by date rows unbounded preceding and current
row) as running_week ( select a.*, case when sum(wwtY) over (order by date rows 1
preceding and 1 preceding) <>sum(wwtY) over (order by date rows current row and current
row) then 1 else 0 end) as week_change_id from yourdata
) as t
I have no access to a db to check the syntax but I guess this should to the calculation....
Ulrich
|