SSRS显示没有数据的行

时间:2017-03-03 16:54:07

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

我创建了一个报告,显示每种异常类型的异常数量。异常类型转换为数字。每种异常类型都有自己的查询,但我使用" UNION"将它们组合成一列。

我在SSRS中使用以下代码作为父组(= choose(Fields!ExceptionCode.Value) " 1.L" " 2.D" " 3.R" " 4.C" " 5.D2" " 6.C2" " 7.O" " 8.O2" " 9.G" " 10.N" " 11.I" " 12.P&#34)

但是,当没有例外时(参见#6和#11),该行不会出现。是否存在某种功能,即使没有数据,我也可以使用SSRS来包含该行?

以下是表格结束的方式:

enter image description here

查询:

SELECT  [report.silverlake.jha].vwLNMAST.AccountNumber
,   [report.silverlake.jha].vwLNMAST.StatusCode
,   [report.silverlake.jha].vwLNMAST.CustomerShortName
,   [report.silverlake.jha].vwLNMAST.OriginalBalance
    - ISNULL((  SELECT  sum(OriginalBalance) 
                FROM    [report.silverlake.jha].vwLNMAST AS LNMAST_Sold 
                WHERE   JhaPostingDate = @date 
                        AND ParticipationCode = 'S'
                        AND PartialChargeOffAccountNumber = [report.silverlake.jha].vwLNMAST.AccountNumber)
            ,0) 
    AS OrigBalance
,   [report.silverlake.jha].vwLNMAST.QueryBalance 
    + ISNULL((  SELECT  sum(QueryBalance) 
                FROM    [report.silverlake.jha].vwLNMAST AS LNMAST_Sold2 
                WHERE   JhaPostingDate = @date 
                        AND ParticipationCode = 'S'
                        AND PartialChargeOffAccountNumber = [report.silverlake.jha].vwLNMAST.AccountNumber)
            ,0) 
    AS CurrBalance
,   CAST([report.silverlake.jha].vwLNSMTG.SpecialFeature1 AS INT) AS ExceptionCode
,   [report.silverlake.jha].vwLNMAST.CreditRatingCode
,   [report.silverlake.jha].vwLNPDUE.DaysPastDue
,   [report.silverlake.jha].vwLNMAST.OriginalLoanDate
,   [report.silverlake.jha].vwLNMAST.MaturityDate
,   [report.silverlake.jha].vwLNMAST.DateLastRenewal
,   [report.silverlake.jha].vwLNMAST.ShadowStatusCode
,   [report.silverlake.jha].vwLNMAST.OfficerCode
FROM [report.silverlake.jha].vwLNMAST
    LEFT OUTER JOIN [report.silverlake.jha].vwLNPDUE
    ON [report.silverlake.jha].vwLNPDUE.JhaKeyAccount =     [report.silverlake.jha].vwLNMAST.JhaKeyAccount
    AND [report.silverlake.jha].vwLNPDUE.JhaPostingDate = [report.silverlake.jha].vwLNMAST.JhaPostingDate
    LEFT OUTER JOIN [report.silverlake.jha].vwLNSMTG
    ON [report.silverlake.jha].vwLNSMTG.JhaKeyAccount = [report.silverlake.jha].vwLNMAST.JhaKeyAccount
    AND [report.silverlake.jha].vwLNSMTG.JhaPostingDate = [report.silverlake.jha].vwLNMAST.JhaPostingDate
WHERE
    [report.silverlake.jha].vwLNMAST.JhaPostingDate = @date
AND [report.silverlake.jha].vwLNMAST.StatusCode NOT IN (2,8)
AND [report.silverlake.jha].vwLNMAST.ParticipationCode <>'S'
AND [report.silverlake.jha].vwLNSMTG.SpecialFeature1 <> ''

UNION

SELECT  [report.silverlake.jha].vwLNMAST.AccountNumber
,   [report.silverlake.jha].vwLNMAST.StatusCode
,   [report.silverlake.jha].vwLNMAST.CustomerShortName
,   [report.silverlake.jha].vwLNMAST.OriginalBalance
    - ISNULL((  SELECT  sum(OriginalBalance) 
                FROM    [report.silverlake.jha].vwLNMAST AS LNMAST_Sold 
                WHERE   JhaPostingDate = @date 
                        AND ParticipationCode = 'S'
                        AND PartialChargeOffAccountNumber = [report.silverlake.jha].vwLNMAST.AccountNumber)
            ,0) 
    AS OrigBalance
,   [report.silverlake.jha].vwLNMAST.QueryBalance 
    + ISNULL((  SELECT  sum(QueryBalance) 
                FROM    [report.silverlake.jha].vwLNMAST AS LNMAST_Sold2 
                WHERE   JhaPostingDate = @date 
                        AND ParticipationCode = 'S'
                        AND PartialChargeOffAccountNumber = [report.silverlake.jha].vwLNMAST.AccountNumber)
            ,0) 
    AS CurrBalance
,   CAST([report.silverlake.jha].vwLNSMTG.SpecialFeature2 AS INT) AS ExceptionCode
,   [report.silverlake.jha].vwLNMAST.CreditRatingCode
,   [report.silverlake.jha].vwLNPDUE.DaysPastDue
,   [report.silverlake.jha].vwLNMAST.OriginalLoanDate
,   [report.silverlake.jha].vwLNMAST.MaturityDate
,   [report.silverlake.jha].vwLNMAST.DateLastRenewal
,   [report.silverlake.jha].vwLNMAST.ShadowStatusCode
,   [report.silverlake.jha].vwLNMAST.OfficerCode
FROM [report.silverlake.jha].vwLNMAST
    LEFT OUTER JOIN [report.silverlake.jha].vwLNPDUE
    ON [report.silverlake.jha].vwLNPDUE.JhaKeyAccount = [report.silverlake.jha].vwLNMAST.JhaKeyAccount
    AND [report.silverlake.jha].vwLNPDUE.JhaPostingDate = [report.silverlake.jha].vwLNMAST.JhaPostingDate
    LEFT OUTER JOIN [report.silverlake.jha].vwLNSMTG
    ON [report.silverlake.jha].vwLNSMTG.JhaKeyAccount = [report.silverlake.jha].vwLNMAST.JhaKeyAccount
    AND [report.silverlake.jha].vwLNSMTG.JhaPostingDate = [report.silverlake.jha].vwLNMAST.JhaPostingDate
WHERE
    [report.silverlake.jha].vwLNMAST.JhaPostingDate = @date
AND [report.silverlake.jha].vwLNMAST.StatusCode NOT IN (2,8)
AND [report.silverlake.jha].vwLNMAST.ParticipationCode <>'S'
AND [report.silverlake.jha].vwLNSMTG.SpecialFeature2 <> ''

UNION

SELECT  [report.silverlake.jha].vwLNMAST.AccountNumber
,   [report.silverlake.jha].vwLNMAST.StatusCode
,   [report.silverlake.jha].vwLNMAST.CustomerShortName
,   [report.silverlake.jha].vwLNMAST.OriginalBalance
    - ISNULL((  SELECT  sum(OriginalBalance) 
                FROM    [report.silverlake.jha].vwLNMAST AS LNMAST_Sold 
                WHERE   JhaPostingDate = @date 
                        AND ParticipationCode = 'S'
                        AND PartialChargeOffAccountNumber = [report.silverlake.jha].vwLNMAST.AccountNumber)
            ,0) 
    AS OrigBalance
,   [report.silverlake.jha].vwLNMAST.QueryBalance 
    + ISNULL((  SELECT  sum(QueryBalance) 
                FROM    [report.silverlake.jha].vwLNMAST AS LNMAST_Sold2 
                WHERE   JhaPostingDate = @date 
                        AND ParticipationCode = 'S'
                        AND PartialChargeOffAccountNumber = [report.silverlake.jha].vwLNMAST.AccountNumber)
            ,0) 
    AS CurrBalance
,   CAST([report.silverlake.jha].vwLNSMTG.SpecialFeature3 AS INT) AS ExceptionCode
,   [report.silverlake.jha].vwLNMAST.CreditRatingCode
,   [report.silverlake.jha].vwLNPDUE.DaysPastDue
,   [report.silverlake.jha].vwLNMAST.OriginalLoanDate
,   [report.silverlake.jha].vwLNMAST.MaturityDate
,   [report.silverlake.jha].vwLNMAST.DateLastRenewal
,   [report.silverlake.jha].vwLNMAST.ShadowStatusCode
,   [report.silverlake.jha].vwLNMAST.OfficerCode
FROM [report.silverlake.jha].vwLNMAST
    LEFT OUTER JOIN [report.silverlake.jha].vwLNPDUE
    ON [report.silverlake.jha].vwLNPDUE.JhaKeyAccount = [report.silverlake.jha].vwLNMAST.JhaKeyAccount
    AND [report.silverlake.jha].vwLNPDUE.JhaPostingDate = [report.silverlake.jha].vwLNMAST.JhaPostingDate
    LEFT OUTER JOIN [report.silverlake.jha].vwLNSMTG
    ON [report.silverlake.jha].vwLNSMTG.JhaKeyAccount = [report.silverlake.jha].vwLNMAST.JhaKeyAccount
    AND [report.silverlake.jha].vwLNSMTG.JhaPostingDate = [report.silverlake.jha].vwLNMAST.JhaPostingDate
WHERE
    [report.silverlake.jha].vwLNMAST.JhaPostingDate = @date
AND [report.silverlake.jha].vwLNMAST.StatusCode NOT IN (2,8)
AND [report.silverlake.jha].vwLNMAST.ParticipationCode <>'S'
AND [report.silverlake.jha].vwLNSMTG.SpecialFeature3 <> ''

UNION

SELECT  [report.silverlake.jha].vwLNMAST.AccountNumber
,   [report.silverlake.jha].vwLNMAST.StatusCode
,   [report.silverlake.jha].vwLNMAST.CustomerShortName
,   [report.silverlake.jha].vwLNMAST.OriginalBalance
    - ISNULL((  SELECT  sum(OriginalBalance) 
                FROM    [report.silverlake.jha].vwLNMAST AS LNMAST_Sold 
                WHERE   JhaPostingDate = @date 
                        AND ParticipationCode = 'S'
                        AND PartialChargeOffAccountNumber = [report.silverlake.jha].vwLNMAST.AccountNumber)
            ,0) 
    AS OrigBalance
,   [report.silverlake.jha].vwLNMAST.QueryBalance 
    + ISNULL((  SELECT  sum(QueryBalance) 
                FROM    [report.silverlake.jha].vwLNMAST AS LNMAST_Sold2 
                WHERE   JhaPostingDate = @date 
                        AND ParticipationCode = 'S'
                        AND PartialChargeOffAccountNumber = [report.silverlake.jha].vwLNMAST.AccountNumber)
            ,0) 
    AS CurrBalance
,   CAST([report.silverlake.jha].vwLNSMTG.SpecialFeature4 AS INT) AS ExceptionCode
,   [report.silverlake.jha].vwLNMAST.CreditRatingCode
,   [report.silverlake.jha].vwLNPDUE.DaysPastDue
,   [report.silverlake.jha].vwLNMAST.OriginalLoanDate
,   [report.silverlake.jha].vwLNMAST.MaturityDate
,   [report.silverlake.jha].vwLNMAST.DateLastRenewal
,   [report.silverlake.jha].vwLNMAST.ShadowStatusCode
,   [report.silverlake.jha].vwLNMAST.OfficerCode
FROM [report.silverlake.jha].vwLNMAST
    LEFT OUTER JOIN [report.silverlake.jha].vwLNPDUE
    ON [report.silverlake.jha].vwLNPDUE.JhaKeyAccount = [report.silverlake.jha].vwLNMAST.JhaKeyAccount
    AND [report.silverlake.jha].vwLNPDUE.JhaPostingDate = [report.silverlake.jha].vwLNMAST.JhaPostingDate
    LEFT OUTER JOIN [report.silverlake.jha].vwLNSMTG
    ON [report.silverlake.jha].vwLNSMTG.JhaKeyAccount = [report.silverlake.jha].vwLNMAST.JhaKeyAccount
    AND [report.silverlake.jha].vwLNSMTG.JhaPostingDate = [report.silverlake.jha].vwLNMAST.JhaPostingDate
WHERE
    [report.silverlake.jha].vwLNMAST.JhaPostingDate = @date
AND [report.silverlake.jha].vwLNMAST.StatusCode NOT IN (2,8)
AND [report.silverlake.jha].vwLNMAST.ParticipationCode <>'S'
AND [report.silverlake.jha].vwLNSMTG.SpecialFeature4 <> ''

UNION

SELECT  [report.silverlake.jha].vwLNMAST.AccountNumber
,   [report.silverlake.jha].vwLNMAST.StatusCode
,   [report.silverlake.jha].vwLNMAST.CustomerShortName
,   [report.silverlake.jha].vwLNMAST.OriginalBalance
    - ISNULL((  SELECT  sum(OriginalBalance) 
                FROM    [report.silverlake.jha].vwLNMAST AS LNMAST_Sold 
                WHERE   JhaPostingDate = @date 
                        AND ParticipationCode = 'S'
                        AND PartialChargeOffAccountNumber = [report.silverlake.jha].vwLNMAST.AccountNumber)
            ,0) 
    AS OrigBalance
,   [report.silverlake.jha].vwLNMAST.QueryBalance 
    + ISNULL((  SELECT  sum(QueryBalance) 
                FROM    [report.silverlake.jha].vwLNMAST AS LNMAST_Sold2 
                WHERE   JhaPostingDate = @date 
                        AND ParticipationCode = 'S'
                        AND PartialChargeOffAccountNumber = [report.silverlake.jha].vwLNMAST.AccountNumber)
            ,0) 
    AS CurrBalance
,   CAST([report.silverlake.jha].vwLNSMTG.SpecialFeature5 AS INT) AS ExceptionCode
,   [report.silverlake.jha].vwLNMAST.CreditRatingCode
,   [report.silverlake.jha].vwLNPDUE.DaysPastDue
,   [report.silverlake.jha].vwLNMAST.OriginalLoanDate
,   [report.silverlake.jha].vwLNMAST.MaturityDate
,   [report.silverlake.jha].vwLNMAST.DateLastRenewal
,   [report.silverlake.jha].vwLNMAST.ShadowStatusCode
,   [report.silverlake.jha].vwLNMAST.OfficerCode
FROM [report.silverlake.jha].vwLNMAST
    LEFT OUTER JOIN [report.silverlake.jha].vwLNPDUE
    ON [report.silverlake.jha].vwLNPDUE.JhaKeyAccount = [report.silverlake.jha].vwLNMAST.JhaKeyAccount
    AND [report.silverlake.jha].vwLNPDUE.JhaPostingDate = [report.silverlake.jha].vwLNMAST.JhaPostingDate
    LEFT OUTER JOIN [report.silverlake.jha].vwLNSMTG
    ON [report.silverlake.jha].vwLNSMTG.JhaKeyAccount = [report.silverlake.jha].vwLNMAST.JhaKeyAccount
    AND [report.silverlake.jha].vwLNSMTG.JhaPostingDate = [report.silverlake.jha].vwLNMAST.JhaPostingDate
WHERE
    [report.silverlake.jha].vwLNMAST.JhaPostingDate = @date
AND [report.silverlake.jha].vwLNMAST.StatusCode NOT IN (2,8)
AND [report.silverlake.jha].vwLNMAST.ParticipationCode <>'S'
AND [report.silverlake.jha].vwLNSMTG.SpecialFeature5 <> ''

UNION

SELECT  [report.silverlake.jha].vwLNMAST.AccountNumber
,   [report.silverlake.jha].vwLNMAST.StatusCode
,   [report.silverlake.jha].vwLNMAST.CustomerShortName
,   [report.silverlake.jha].vwLNMAST.OriginalBalance
    - ISNULL((  SELECT  sum(OriginalBalance) 
                FROM    [report.silverlake.jha].vwLNMAST AS LNMAST_Sold 
                WHERE   JhaPostingDate = @date 
                        AND ParticipationCode = 'S'
                        AND PartialChargeOffAccountNumber = [report.silverlake.jha].vwLNMAST.AccountNumber)
            ,0) 
    AS OrigBalance
,   [report.silverlake.jha].vwLNMAST.QueryBalance 
    + ISNULL((  SELECT  sum(QueryBalance) 
                FROM    [report.silverlake.jha].vwLNMAST AS LNMAST_Sold2 
                WHERE   JhaPostingDate = @date 
                        AND ParticipationCode = 'S'
                        AND PartialChargeOffAccountNumber = [report.silverlake.jha].vwLNMAST.AccountNumber)
            ,0) 
    AS CurrBalance
,   CAST([report.silverlake.jha].vwLNSMTG.SpecialFeature6 AS INT) AS ExceptionCode
,   [report.silverlake.jha].vwLNMAST.CreditRatingCode
,   [report.silverlake.jha].vwLNPDUE.DaysPastDue
,   [report.silverlake.jha].vwLNMAST.OriginalLoanDate
,   [report.silverlake.jha].vwLNMAST.MaturityDate
,   [report.silverlake.jha].vwLNMAST.DateLastRenewal
,   [report.silverlake.jha].vwLNMAST.ShadowStatusCode
,   [report.silverlake.jha].vwLNMAST.OfficerCode
FROM [report.silverlake.jha].vwLNMAST
    LEFT OUTER JOIN [report.silverlake.jha].vwLNPDUE
    ON [report.silverlake.jha].vwLNPDUE.JhaKeyAccount = [report.silverlake.jha].vwLNMAST.JhaKeyAccount
    AND [report.silverlake.jha].vwLNPDUE.JhaPostingDate = [report.silverlake.jha].vwLNMAST.JhaPostingDate
    LEFT OUTER JOIN [report.silverlake.jha].vwLNSMTG
    ON [report.silverlake.jha].vwLNSMTG.JhaKeyAccount = [report.silverlake.jha].vwLNMAST.JhaKeyAccount
    AND [report.silverlake.jha].vwLNSMTG.JhaPostingDate = [report.silverlake.jha].vwLNMAST.JhaPostingDate
WHERE
    [report.silverlake.jha].vwLNMAST.JhaPostingDate = @date
AND [report.silverlake.jha].vwLNMAST.StatusCode NOT IN (2,8)
AND [report.silverlake.jha].vwLNMAST.ParticipationCode <>'S'
AND [report.silverlake.jha].vwLNSMTG.SpecialFeature6 <> ''
ORDER BY AccountNumber

1 个答案:

答案 0 :(得分:0)

我会尝试包装这些

的所有实例
,   [report.silverlake.jha].vwLNMAST.OriginalBalance
,   [report.silverlake.jha].vwLNMAST.QueryBalance
<\ n>使用ISNULL()。看起来你用右侧操作数加上或减去它来做这个,但是如果OriginalBalance或QueryBalance是NULL,那么你的算术将产生一个NULL