Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 有没有办法在SSRS中使用计算表达式作为参数?_Sql Server_Sql Server 2008_Reporting Services_Ssrs 2008_Ssrs 2008 R2 - Fatal编程技术网

Sql server 有没有办法在SSRS中使用计算表达式作为参数?

Sql server 有没有办法在SSRS中使用计算表达式作为参数?,sql-server,sql-server-2008,reporting-services,ssrs-2008,ssrs-2008-r2,Sql Server,Sql Server 2008,Reporting Services,Ssrs 2008,Ssrs 2008 R2,我不能像对待两个非计算参数那样在数据集中写入参数。如果我走错了路,非常感谢您的帮助,让我走上正轨 数据集查询 SELECT Inmast.fpartno , inmast.fdescript , inmast.fonhand , inmast.fnonnetqty , inmast.fcstscode , inmast.fsource , inmast.fprodcl , inprod.fpc_desc , inmast.

我不能像对待两个非计算参数那样在数据集中写入参数。如果我走错了路,非常感谢您的帮助,让我走上正轨

数据集查询

SELECT 
    Inmast.fpartno
    , inmast.fdescript
    , inmast.fonhand
    , inmast.fnonnetqty
    , inmast.fcstscode
    , inmast.fsource
    , inmast.fprodcl
    , inprod.fpc_desc
    , inmast.fsafety
    , inmast.fbook
    , inmast.fonorder
    , inmast.fproqty
    , inmast.freordqty  
From inmast  
    inner join inprod 
        on inmast.fac + inmast.fprodcl = inprod.fac + inprod.fpc_number  
Where inmast.fcstscode = @Code and inmast.fsource = @Source 
计算表达式

(inmast.fonhand 
    + inmast.fonorder 
    + inmast.fproqty 
    - inmast.fbook 
    - inmast.fnonnetqty 
    - inmast.fsafety < 0
) = @CalculatedExpression
(inmaster.fonhand
+英马斯特·方诺德酒店
+inmast.fproqty
-英马斯特·布克
-英马斯特·弗奈蒂
-标准安全性<0
)=@计算表达式

不能使用数据集中的值来创建参数值。该参数用于创建数据集,因此该参数的值不可用

我相信这会完成你想做的事情。首先,您的新查询是:

SELECT 
Inmast.fpartno
, inmast.fdescript
, inmast.fonhand
, inmast.fnonnetqty
, inmast.fcstscode
, inmast.fsource
, inmast.fprodcl
, inprod.fpc_desc
, inmast.fsafety
, inmast.fbook
, inmast.fonorder
, inmast.fproqty
, inmast.freordqty
From inmast  
inner join inprod 
    on inmast.fac + inmast.fprodcl = inprod.fac + inprod.fpc_number  
Where inmast.fcstscode = @Code and inmast.fsource = @Source
and  CASE WHEN 
(inmast.fonhand 
+ inmast.fonorder 
+ inmast.fproqty 
- inmast.fbook 
- inmast.fnonnetqty 
- inmast.fsafety
) < 0 THEN 0 ELSE 1 END = @CalculatedValue 
选择
圣帕特诺
,inmast.fdescript
,英马斯特·丰汉德
,inmaster.fnonetqty
,inmast.fcstscode
,inmast.fsource
,inmast.fprodcl
,inprod.fpc_desc
,inmast.fsafety
,inmast.fbook
,inmast.fonorder
,inmaster.fproqty
,inmaster.freordqty
来自英马斯特
内连接杆
关于inmaster.fac+inmaster.fprodcl=inprod.fac+inprod.fpc\u编号
其中inmaster.fcstscode=@Code和inmaster.fsource=@Source
什么时候呢
(因马斯特·丰汉德)
+英马斯特·方诺德酒店
+inmast.fproqty
-英马斯特·布克
-英马斯特·弗奈蒂
-国际海事安全
)<0然后0否则1结束=@CalculatedValue
接下来,您将为名为@CalculatedValue的新参数创建两个默认值

  • 标签“小于0”和值0
  • 标签“大于0”和值1

  • 发生的情况是,如果计算的总和小于0,case语句将返回0。如果大于等于0,则返回1。您的@CalculatedValue将与该值匹配,以适当地筛选结果。

    您能将该数据集查询更改为存储过程调用吗?看起来你的计算表达式有错,顺便说一句,我还没试过。对于SSRS来说还是相当新的,但会尝试一下。计算表达式是
    Where
    子句的一部分吗?是的,应该放在那里。好的-让我们知道如何将其转换为存储过程。非常感谢您的帮助。我在工作中被这件事困扰了好几天。这将对我以后的报告有很大帮助。