--测试环境
declare @表a table (编号 varchar(3),数量 int ,单价 money)
insert into @表a select '001',1,100
union all select '002',1,120
union all select '003',5,300
union all select '001',2,110
union all select '002',1,110
--查询语句
select 编号,加权平均单价=sum(单价*数量)/sum(数量)
from @表a
group by 编号
--结果
编号 平均单价
---- ---------------------
001 106.6666
002 115.0000
003 300.0000