0

在从 2 个不同的表计算之后sum(frequency * weight),如果总和大于某个数字,我试图打印出一个语句(如下),但我不断收到一个错误,说total这不是一个有效的列。

任何帮助,将不胜感激。提前致谢

DECLARE @total INT

SELECT SUM(frequency * weight) AS total
  FROM WF, WW
 WHERE WF.word = WW.word

IF total > 30
BEGIN
  print 'Alert! Bullying post'
END
ELSE
BEGIN
  print'Normal Post'
END
4

1 回答 1

0
declare @Total as Int;

select @Total = Sum( WF.Frequency * WW.Weight )
  from WF inner join
    WW on WW.Word = WF.Word;

print case when @Total > 30 then 'Alert! Bullying post!' else 'Normal post.' end;
于 2013-09-08T00:46:57.773 回答