so I have table that consist : table, shop_id, and transaction amount.
date_key shop_id transaction_amount
2022-01-01 S_001 2000
2022-01-01 S_002 2500
2022-01-02 S_001 2600
2022-01-02 S_002 2200
.
.
.
.
the goal is I want to calculate the % of transaction amount of top 1000 sellers MTD. on average I have around 50k sellers that has transaction on each day. since the calculation is month to date, so there's possibility if we will find different top 1000 sellers on each day.
top 1000 seller mtd meaning : the performance is based on cumulative MTD transaction amount e.g for data on 2022-01-05 the we need to calculate cumulative transaction amount from 2022-01-01 to 2022-01-04 for each shop_id then sort it based on highest transaction amount.
the goal is to create table below
date_key amount_from_top_1000_sellers(a) amount_from_all_sellers (b) ratio (a/b)
2022-01-01 4000 200000 2%
...
...
...