By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
12 rows affected
| Col_A | Col_B | DistinctCount |
|---|---|---|
| A | 3 | 3 |
| A | 2 | 3 |
| A | 2 | 3 |
| A | 2 | 3 |
| A | 1 | 3 |
| A | 1 | 3 |
| b | 5 | 2 |
| b | 4 | 2 |
| b | 4 | 2 |
| C | 6 | 1 |
| C | 6 | 1 |
| C | null | 1 |
Warning: Null value is eliminated by an aggregate or other SET operation.