Hive: Sum over a specified group (HiveQL)

后端 未结 6 832
渐次进展
渐次进展 2021-02-04 14:49

I have a table:

key    product_code    cost
1      UK              20
1      US              10
1      EU              5
2      UK              3
2      EU               


        
6条回答
  •  抹茶落季
    2021-02-04 15:10

    This query gives me perfect result

    select key, product_code, cost, sum(cost) over (partition by key) as total_costs from zone;

提交回复
热议问题