你这是存储过程还是什么的?select 的语句的话好像不对吧,没看到你的变量
---------
@记帐人
-----
在什么地方声明
至少你应该这样
--------------declare @记帐人 varchar(20)
select @记帐人 = 'XXXXX'----------然后:
select * from (SELECT 部门,组别,货号,批号,批次,'数量ALL'=sum(数量) FROM 销售单
where 状态='待审' and 记帐人 = @记帐人 GROUP BY 部门,组别,货号,批号,批次
)as lsj left join 批次库存库 on
批次库存库.部门=LSj.部门 AND 批次库存库.货号=LSj.货号 AND 批次库存库.批号=LSj.批号 AND 批次库存库.组别=LSJ.组别
and 批次库存库.批次=lsj.批次 where (case when 库存数量 is null then 0 else 库存数量 end )-数量ALL < -0.0001
---------
@记帐人
-----
在什么地方声明
至少你应该这样
--------------declare @记帐人 varchar(20)
select @记帐人 = 'XXXXX'----------然后:
select * from (SELECT 部门,组别,货号,批号,批次,'数量ALL'=sum(数量) FROM 销售单
where 状态='待审' and 记帐人 = @记帐人 GROUP BY 部门,组别,货号,批号,批次
)as lsj left join 批次库存库 on
批次库存库.部门=LSj.部门 AND 批次库存库.货号=LSj.货号 AND 批次库存库.批号=LSj.批号 AND 批次库存库.组别=LSJ.组别
and 批次库存库.批次=lsj.批次 where (case when 库存数量 is null then 0 else 库存数量 end )-数量ALL < -0.0001
解决方案 »
- sql语句优化求教。
- SQL 连续值 统计问题
- 如何利用flashfxp上传sql server?请高手指点。要多少分给多少分
- 作业一直运行停止不了
- not in(或者 not exists)问题~~·出现遗漏数据【2】
- 救命啊 我想活下去 (在线等)
- 本人正在开发一个外国博客网需要世界国家和城市数据库....求助~~~
- SQL SERVER 2k &Oracle 数据交换问题
- 真很奇怪,如果(ACCESS)表中有数据,我删空后就不能保存,以下错误信息。但如果新增记录,不输入数据可以保存。
- 迷惑的问题
- 小弟请教一个SQL:"将列更新从一个表传递到另一个表"
- sql server2000启动问题
select @记帐人='XXX'
select * from
(SELECT 部门,组别,货号,批号,批次,'数量ALL'=sum(数量) FROM 销售单
where 状态='待审' and 记帐人 = @记帐人 GROUP BY 部门,组别,货号,批号,批次
)as lsj left join 批次库存库 on
批次库存库.部门=LSj.部门 AND 批次库存库.货号=LSj.货号 AND 批次库存库.批号=LSj.批号 AND 批次库存库.组别=LSJ.组别
and 批次库存库.批次=lsj.批次 where (case when 库存数量 is null then 0 else 库存数量 end )-数量ALL < -0.0001
--或者
declare @记帐人 varchar(20)
select @记帐人='XXX'
select * from
(SELECT 部门,组别,货号,批号,批次,'数量ALL'=sum(数量) FROM 销售单
where 状态='待审' and 记帐人 = 'XXX' GROUP BY 部门,组别,货号,批号,批次
)as lsj left join 批次库存库 on
批次库存库.部门=LSj.部门 AND 批次库存库.货号=LSj.货号 AND 批次库存库.批号=LSj.批号 AND 批次库存库.组别=LSJ.组别
and 批次库存库.批次=lsj.批次 where (case when 库存数量 is null then 0 else 库存数量 end )-数量ALL < -0.0001--以上不行吗?
set @记帐人='XXX'
把上面两句加上