(Sorry if it's a repost, but I have had problems with overquoting and an answer that disappeared) You are absolutely right, I had misread the case and missed the sliding window in the sum (something I don't use very often, perhaps I should use it more). Very good idea. Stephane Faroult RoughSea Ltd <http://www.roughsea.com> Konagora <http://www.konagora.com> RoughSea Channel on Youtube <http://www.youtube.com/user/roughsealtd> Alex Fatkulin wrote: > now it won't miss anything, you can get my query and verify yourself > > On Mon, Jul 5, 2010 at 3:49 PM, Stephane Faroult <sfaroult@xxxxxxxxxxxx> > wrote: > >> Well, sum (case ... end) is very like a count, when the case returns >> either 0 or 1. >> >> Unless I have missed something, if you have this data: >> > -- //www.freelists.org/webpage/oracle-l