SSRS中多值引數處理

2022-07-12 19:27:14 字數 1049 閱讀 1488

1. @joinid=join(parameters!pn_id.value,",")

將多值引數的值用逗號連線成乙個字串,

( select '''+replace(@pn_id,',',''' pid union all select ''')+''' pid) 

將字串通過replace,uniion轉換成一張表

注意: union 和union all 區別, union無重複行,union all 不剔除重複行

將字串轉換成一張表後再進行查詢就方便了,下面這個例子就是將字串轉換為c表後,找出在c表而不在a表中的記錄,並給出乙個not exists的記錄

select c.pid,''not exists'' as pstate from( select '''+replace(@joinid,',',''' pid union all select ''')+''' pid ) c where c.pid not in

(select pn_id from pen_link_component a with (nolock))'

2. 還有另一種方法將字串分割並轉換成一張表

declare @tb table(b varchar(max))

insert into @tb select @joinid b ;

select c.split,'not exists' as pstate from (

select substring(t.b, number ,charindex(',',t.b+',',number)-number) as split

from @tb t,master..spt_values s where s.number >=1 and s.type = 'p' and substring(','+t.b,s.number,1) = ',' ) c where c.split not in

(select pn_id from pen_link_component with (nolock))

利用charindex函式和master..spt_values表中的number來將進行分割

python 多值引數

黑馬程式設計師課程筆記 定義支援多指引數的函式有時可能需要乙個函式能夠處理的引數的個數是不確定的,這個時候,就可以使用多值引數。在python中有兩種多值引數 引數名前增加乙個可以接收元組 引數名前增加兩個可以接收字典 一般在給多值引數命名時。習慣使用以下兩個名字 args 存放元組引數 前面有乙個...

Python中的多值引數

def plot a,b,args,kwargs pass關於其中的引數部分 args,kwargs 許多人不是特別清晰,看到了許多介紹的文章,也覺得沒有說的特別清楚。其實,可以將上述引數部分 a,b,args,kwargs 分成3個部分 a,b 是固定引數,不可缺少,也必須是需要的資料型別 arg...

python之多值引數

多值引數 定義支援多值引數的函式 一般在給多值引數命名時,習慣使用以下兩個名字 args是arguments的縮寫,有變數的含義 kw是keyword的縮寫,kwargs可以記憶鍵值對引數 def demo num,args,kwargs print num print args print kwa...