Archives of the TeradataForum
Message Posted: Tue, 01 Dec 2009 @ 20:47:03 GMT
Subj: | | Re: Incrementing count within a group of records |
|
From: | | ulrich arndt |
Hi David,
Dieters solution will be the fastes.
It should be also possible if you can use a derived table. Will also work if your group definition is not numeric :-)...
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
|