create proc FOOD_SALES_INIT @time_year char(10),@time_mont char(10)
as
update FOOD_SALES
set
FOODS_SUM=(
select sum(GOODS_PRICE * KG) from FOOD_SALES where TIME_YEAR=@time_year and TIME_MONT=@time_mont
)update FOOD_SALES
set
PRICE_ACCU=(
select sum(FOOD_SUM) from FOOD_SALES where TIME_MONT>'01' and TIME_MONT<@time_mont and
TIME_YEAR=@time_year and TIME_MONT=@time_mont
)
as
update FOOD_SALES
set
FOODS_SUM=(
select sum(GOODS_PRICE * KG) from FOOD_SALES where TIME_YEAR=@time_year and TIME_MONT=@time_mont
)update FOOD_SALES
set
PRICE_ACCU=(
select sum(FOOD_SUM) from FOOD_SALES where TIME_MONT>'01' and TIME_MONT<@time_mont and
TIME_YEAR=@time_year and TIME_MONT=@time_mont
)
asupdate FOOD_SALES
set FOODS_SUM=(
select GOODS_PRICE * KG from FOOD_SALES where TIME_YEAR=@time_year and TIME_MONT=@time_mont)
update FOOD_SALES
set PRICE_ACCU= (select sum(FOOD_SUM) from FOOD_SALES where TIME_MONT>'01' and TIME_MONT<@time_mont and
TIME_YEAR=@time_year and TIME_MONT=@time_mont)
go
as
update FOOD_SALES
set
FOODS_SUM=
GOODS_PRICE * KG from FOOD_SALES where TIME_YEAR=@time_year and TIME_MONT=@time_mont
update FOOD_SALES
set
PRICE_ACCU=
sum(FOOD_SUM) from FOOD_SALES where TIME_MONT>'01' and TIME_MONT<@time_mont and
TIME_YEAR=@time_year and TIME_MONT=@time_mont
这样也可以
update t_table set f1 = (select ff1 from t_t1) where ....