我有一张表,其中我有以下列
FirstDate,
LastDate,
Grade_Category,
CR_Tones,
CR_grade
我创建了一个查询,其中此数据按日期和材料类型分组。
这是我设计的查询,我将移动日期,等级类别等归为总和色调等。
答案 0 :(得分:0)
如下所示的查询可以是一个很好的起点
select
lastdate as [date],
grade_category as [material type],
SUM(CR_grade*CR_Tones)/SUM(CR_Tones) as [weighted grade]
from table
group by lastdate, grade_category
答案 1 :(得分:0)
看起来你正在寻找分组集
select
lastdate as [date],
grade_category as [material type],
SUM(CR_grade*CR_Tones)/SUM(CR_Tones) as weightedgrade --your formula for weighted grade
from yourtable
group by Grouping Sets (lastdate, grade_category)