当前位置: 代码迷 >> 其他数据库 >> 紧急求高手,该如何处理
  详细解决方案

紧急求高手,该如何处理

热度:1211   发布时间:2013-02-26 00:00:00.0
紧急求高手
下面写sqlserver2000 的存储过程
 为什么报错

create PROCEDURE p1 
@nian int,@yue int ,@chanpingname varchar(50),
@maoyileixing varchar(50),@qiyemingchen varchar(50),
@bycz float output,@bycl float output,
@ljcz float output,@ljcl float output,
@sntqcz float output,@sntqcl float output
as
declare @_snnf int;
begin
SELECT @bycl=SUM(zongzhong) AS chanliang,
  @bycz=SUM(allprice) AS chanzhi
FROM ccmxb
WHERE (tianbaoshijian = @nian+'/'+@yue)
GROUP BY @chanpingname,@maoyileixing,@qiyemingchen;

SELECT @ljcl=SUM(zongzhong) AS chanliang,
  @ljcz =SUM(allprice) AS chanzhi
FROM ccmxb
WHERE (tianbaoshijian like @nian)
GROUP BY @chanpingname,@maoyileixing,@qiyemingchen;

set @_snnf=@nian-1;

SELECT @sntqcl=SUM(zongzhong) AS chanliang,
  @sntqcz =SUM(allprice) AS chanzhi
FROM ccmxb
WHERE (tianbaoshijian like @_snnf)
GROUP BY @chanpingname,@maoyileixing,@qiyemingchen;



end

------解决方案--------------------------------------------------------
SELECT @bycl=SUM(zongzhong) AS chanliang,
  @bycz=SUM(allprice) AS chanzhi
FROM ccmxb
WHERE (tianbaoshijian = @nian+'/'+@yue)
GROUP BY @chanpingname,@maoyileixing,@qiyemingchen;

这样的语句需要拼接成动态的
  相关解决方案