亲爱的,我试图将查询添加到crystal report命令中 查询是
Declare @FromDate Datetime
Declare @ToDate Datetime
Declare @Whse nvarchar(10)
select @FromDate = min(S0.Docdate) from dbo.OINM S0 where S0.Docdate >={?@FromDate}
select @ToDate = max(S1.Docdate) from dbo.OINM s1 where S1.Docdate <={?@ToDate}
select @Whse = Max(s2.Warehouse) from dbo.OINM S2 Where S2.Warehouse ='[%2]'
Select @Whse as 'Warehouse', a.Itemcode, max(a.Dscription) as ItemName,
sum(a.OpeningBalance) as OpeningBalance, sum(a.INq) as 'IN', sum(a.OUT) as OUT,
..
.. .. .. 原始查询是...从dbo.OINM S0中选择@FromDate = min(S0.Docdate),其中S0.Docdate&gt; ='[%0]' 从dbo.OINM s1中选择@ToDate = max(S1.Docdate),其中S1.Docdate&lt; ='[%1]' 从dbo.OINM S2中选择@Whse = Max(s2.Warehouse)其中S2.Warehouse ='[%2]' 我将'[%0]更改为&gt; = {?@ FromDate}(参数)并且对于'[%1]'工作正常,现在我无法更改'[%2]'对我有用的唯一方法是将其更改为{?@Whse},但这会在报告中给出错误的数据 问候
答案 0 :(得分:0)
我不清楚你想从where子句中获取什么,但是如果你想用文本获得那些仓库:2%你可以试试吗?
试试这些:
select @Whse = Max(s2.Warehouse) from dbo.OINM S2 Where S2.Warehouse Like '%2'
答案 1 :(得分:0)
将其更改为
从dbo.OINM S2中选择@Whse = Max(s2.Warehouse)其中S2.Warehouse = {?@ select * from OWHS}
它的工作正常,但如果您选择多个仓库,则会出现错误