I have data of products that are sold by various shops. For some shops they are sold with discount mapped by PROMO_FLG.
I would like to display two COUNT PARTITION columns.
+-------------------------+--------------+---------------------+
| Store | Item | PROMO_FLG|
|-------------------------+--------------+---------------------|
| 1 | 1 | 0 |
| 2 | 1 | 1 |
| 3 | 1 | 0 |
| 4 | 1 | 0 |
| 5 | 1 | 1 |
| 6 | 1 | 1 |
| 7 | 1 | 1 |
| 8 | 1 | 0 |
| 9 | 1 | 0 |
| 10 | 1 | 0 |
+-------------------------+--------------+---------------------+
First displays all shops that thave this product (which is done)
COUNT(DISTINCT STORE) OVER (PARTITION ITEM) would give is 10
Second one - which I seek - counts only these shops that have value in PROMO_FLG = 1 attribute.
That should give us value of 4