如何为" retirements
"添加分组?表格由" id_type
"领域,而不只是每个人?
select name,
sum(retirements.price_per_product)
from retirements
join type_of_products top on retirements.id_product = top.id
where (date between '1998-11-01' and '1998-11-14')
group by name;
不要求助于每种类型的汇总功能吗?它太粗鲁了。
答案 0 :(得分:0)
有两种不同的方法可以实现这一目标。
1. You may use a sub-query but it is expensive in terms of performance.
2. You may utilize the #temp table and join it in later part. A downside is it is
编码时间更长,但从长远来看,性能也很好。