SSRS:在从SSRS参数传递值时使用sql where子句中的exists条件

时间:2015-09-09 18:24:49

标签: sql sql-server-2008 reporting-services ssrs-2008 ssrs-2008-r2

Table : incident
----------------
incident_id   usr_id    item_id   Inc_Date
10059926       191       61006    8-22-2015
10054444       222        3232    6-7-2015

Table: act_reg
--------------
 act_reg_id  act_type_id  incident_id    usr_id  act_type_sc
 454244         1        10059926         191    ASSIGN
 471938        115       10059926         191    TRAVEL TIME
 473379        40        10059926         191    FOLLOW UP
 477652        115       10059926         191    TRAVEL TIME
 489091        504       10059926         191    ADD_ATTCHMNTS
 477653        504       10054444         222    ADD_ATTCHMNTS

参数:@attach(value = 1,Label = Yes& Value = 0,Label = No)

 Result (While I am selecting 'Yes' in dropdown)
 ----------------------------------------------
 incident_id   usr_id    item_id  
 10059926       191      61006    
 10054444       222       3232

我的查询:

SELECT  incident.incident_id,incident.usr_id,incident.item_id
FROM  incident 
where exists (select * from act_reg 
              where incident.incident_id = act_reg.incident_id
                  and act_reg.act_type_sc (case when @attach=1 and act_reg.act_type_sc='ADD_ATTCHMNTS' then NULL else act_reg.act_type_sc end  )
           )

请帮我解决这个问题。

1 个答案:

答案 0 :(得分:1)

您应该将查询更改为以下内容: -

    <div class="main-div">
      <div class="float-left">Left1</div>
      <div class="float-right">Right1</div>
    </div>
    </br>
    <div class="main-div">
      <div class="float-right">Right2</div>
      <div class="float-left">Left2</div>
    </div>

<强> SQL Fiddle