简体   繁体   中英

passing [value%] to parameter in crystal report

dear all I tried to add query into crystal report command the query is

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,
..

.. .. .. the original query is ...select @FromDate = min(S0.Docdate) from dbo.OINM S0 where S0.Docdate >='[%0]' select @ToDate = max(S1.Docdate) from dbo.OINM s1 where S1.Docdate <='[%1]' select @Whse = Max(s2.Warehouse) from dbo.OINM S2 Where S2.Warehouse ='[%2]' I changed '[%0] to be >={?@FromDate} (parameter) and it is work fine the same for '[%1]' now I cant change '[%2]' the only thing work with me is to change it into {?@Whse} but this give me wrong data in the report regards

I'm not clear whats are you trying to obtain from the where clause, but if you're trying to obtain those warehouse with the text: 2% you can try like??

Try these:

select @Whse = Max(s2.Warehouse) from dbo.OINM S2 Where S2.Warehouse Like '%2'

change it to

select @Whse = Max(s2.Warehouse) from dbo.OINM S2 Where S2.Warehouse ={?@select*from OWHS}

its work fine but for if you select more than one warehouse you will have error

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM