27,582
社区成员




update [Lggl_Knowledge_words]
set [Lgbianhao] =
isnull(
(
select sum([Mtbianhao]) / count(*)
from [Lggl_Knowledge_Material] m
where m.[word] = [word] and m.[DgPhaseID] = [DgPhaseID]
)
,0)
where DgPhaseID = 1
--try this
update [Lggl_Knowledge_words]
set [Lgbianhao] =
isnull(
(
select sum([Mtbianhao]) / count(*) --avg([Mtbianhao]) 感觉直接平均值也可以
from [Lggl_Knowledge_Material] m
left join [Lggl_Knowledge_words] on m.[word] =l.[word] and m.[DgPhaseID] =l.[DgPhaseID]
)
,0) from Lggl_Knowledge_Material
where DgPhaseID = 1
update [Lggl_Knowledge_words]
set [Lgbianhao] = m.tt
from [Lggl_Knowledge_words] t
inner join
(
select [word],[DgPhaseID],
isnull(sum(m.[Mtbianhao]) *1.0/ count(*),0) as tt
from [Lggl_Knowledge_Material] m
group by [word],[DgPhaseID]
)m
on m.[word] = t.[word] and
m.[DgPhaseID] = t.[DgPhaseID]
--where DgPhaseID = 1