计算列的总和并分配给变量

时间:2013-07-08 10:59:48

标签: hana

我想执行列的总和并将结果分配给变量。我尝试了以下语法。

declare variable double;
 variable:= select sum(cost) from retail 

or 
select sum(cost)from retail into variable.

请建议正确的语法。

2 个答案:

答案 0 :(得分:3)

在HANA的SQLScript中,这将是语法:

declare variable double; 
select sum(cost) into variable from retail;

答案 1 :(得分:0)

如果您使用sql,请尝试以下脚本:

Declare @variable int

Select @variable = sum(cost) from retail

Print @variable

Declare @variable Numeric(18,2)

Select @variable = sum(cost) from retail

Print @variable