Reputation: 92
I am trying to create some columns from a map, can someone help? My query is this:
select
multimap_agg(produtos,amount) products ,"seller" seller from
self_service_data.self_inside_field_sales
where pipeline = '[IS] Closer Pipeline'
group by 2
I have this kind of result:
I am trying get a table with small groups with:
Seller, Number of Products (A+B) sold, sum(amount), Number of Products sold(C+D), sum(amount)
Upvotes: 1
Views: 923
Reputation: 222722
I don't see the point for using maps. From the structure of your expected results, it looks like simple aggregation would get the job done:
select
seller,
produtos,
count(*) no_produtos,
sum(amount) sum_amount
from self_service_data.self_inside_field_sales
where pipeline = '[IS] Closer Pipeline'
group by seller, produtos
Upvotes: 1