求一条sql语句(相加一列中的每项)

如表table 表中的一列为Engish 我要对English的项都相加。请问高手怎么写呢?
帮我看看这个SQL存储过程,哪里不对了!运行正确!

create procedure Getsql
as
begin
declare @people int
Set @people=(select sum(people) from smessage where city='苏州')
update instance set people=@people where city='苏州'
end
------------
我现在的问题是,从表instance中,没有得到任何信息.

如果English是数值型的,那么:

//--求English的总和
select sum(English) from table

另外:

//--求English列的平均数:
select avg(English) from table

最大数用:max(English),最小数用min(English)………………
………………………………
………………………………
温馨提示:答案为网友推荐,仅供参考
第1个回答  2008-12-13
这里不能用set 用select
create procedure Getsql
as
begin
declare @people int
Select @people=(select sum(people) from smessage where city='苏州')

update instance set people=@people where city='苏州'
end
相似回答