我想从我的查询中得到以下结果:
id_product_attribute | id_product | reference | name | total
12 | 1 | 234235 | product_name | 2
14 | 2 | 235435 | product_name | 7
16 | 3 | 235325 | product_name | 4
ETC
但是当我使用这个查询时:
select pa.id_product_attribute, p.id_product, pa.reference, cl.name, sum(od.product_quantity) as total
from ps_product_attribute pa
left join ps_order_detail od on od.product_attribute_id = pa.id_product_attribute
left join ps_product p on pa.id_product = p.id_product
left join ps_category_product cp on cp.id_product = p.id_product
left join ps_category_lang cl on cp.id_category = cl.id_category
where cp.id_category = 141 and cl.id_lang = 6;
它只给我这个结果:
id_product_attribute | id_product | reference | name | total
12 | 1 | 234235 | product_name | 13
所以在“总计”列中,它向我显示了所有的总数,而不是每行单独显示。
谁能告诉我我在查询中做错了什么?