我想执行列的总和并将结果分配给变量。我尝试了以下语法。
declare variable double;
variable:= select sum(cost) from retail
or
select sum(cost)from retail into variable.
请建议正确的语法。
答案 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