Mysql BigQuery/SQL-在特定变量上拆分值

Mysql BigQuery/SQL-在特定变量上拆分值,mysql,google-bigquery,Mysql,Google Bigquery,需要将market_offers列中的重复项替换为所有提供主值的条目的总和。 但有一种情况是,有不同的等级和国家代码 输入 预期结果 country_code rank store_id category_id offers market_offers se 1 14582 1106 410 168 286 se 1 1955 1294 2

需要将market_offers列中的重复项替换为所有提供主值的条目的总和。 但有一种情况是,有不同的等级和国家代码

输入

预期结果

country_code    rank    store_id    category_id offers  market_offers
se              1       14582       1106        410     168 286
se              1       1955        1294        2       168 286
se              1       9831        1158        151     168 286
se              2       666         11158       536     1333
se              2       6587        25863       6586    1333
se              2       6666        158         536     1333
se              5       65853       76722       1521    151
se              5       6587        25863       6586    151

下面考虑一下

select * except(market_offers), 
  round(market_offers / count(1) over(partition by market_offers, rank), 2) as market_offers
from `project.dataset.table`               
如果应用于问题中的样本数据,则输出为


再次感谢:)
select * except(market_offers), 
  round(market_offers / count(1) over(partition by market_offers, rank), 2) as market_offers
from `project.dataset.table`