简体   繁体   中英

Cumulative sum for each bucket of values in SQL

Hi I am looking to build logic using SQL, to achieve below. 在此处输入图像描述

Essentially needing to do the cumsum but only where there are consecutive 1's. It's daily level data.

I have achieved this in Excel by creating two supporting column but not being able to achieve same using SQL ( tried several rankings and partitions but did not work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM