By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
9 rows affected
| memberid | yearmonth | activestatus |
|---|---|---|
| 1 | 202201 | Y |
| 2 | 202201 | N |
| 3 | 202201 | N |
| 3 | 202202 | Y |
| 2 | 202202 | N |
| 1 | 202202 | Y |
| 1 | 202203 | N |
| 2 | 202203 | Y |
| 3 | 202203 | Y |
| yearmonth | distinct_running_count |
|---|---|
| 202201 | 1 |
| 202202 | 2 |
| 202203 | 3 |
Warning: Null value is eliminated by an aggregate or other SET operation.