我认为家庭是购物者的等级制度。因此,我建议使用
group by和窗口函数:
select family_id, shopper_id, product_id, sum(quantity) as total_quantity_shopper, sum(sum(quantity)) over (partition by family_id, product_id) as total_quantity_familyfrom productsgroup by family_id, shopper_id, product_id
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)