获取错误:已添加具有相同密钥的项目 - SSRS报告中的错误/警告

时间:2016-07-08 15:34:41

标签: sql tsql stored-procedures reporting-services

我尝试了很多东西来深入研究这个问题。最后归结为它导致了这个问题"已经添加了具有相同键的项目。",我相信已经存在的相同键,例如a.field01和b。 field02。

这是代码

ALTER PROCEDURE [dbo].[Payroll_Report]

        @Office NVARCHAR(4000),
        @Servicetype NVARCHAR(4000),
        @Start DATETIME,
        @End DATETIME
AS
BEGIN
    SET NOCOUNT ON;

    Select 
    a.owneridname
   ,a.[serviceidname] 
   ,count(case
            when 
                a.[statuscodename] like 'Confirmed' or a.new_approvalstatusname like 'Approved'
            then
                a.serviceid
           end) As 'Total# Confirmed Activities'

    ,CONVERT( NVARCHAR( 16 ), 
            FLOOR( ( sum(case
            when
                a.serviceidname not like 'Indirect' and a.[statuscodename] like 'Confirmed' or a.new_approvalstatusname like 'Approved'
            then    
                a.[scheduleddurationminutes]
            end) ) / 60.0 ) ) 
            + N':' + CONVERT( NVARCHAR( 5 ), CONVERT( INTEGER, 
            FLOOR( (sum(case
            when
                a.serviceidname not like 'Indirect' 
            then    
                a.[scheduleddurationminutes]
            end)) % 60.0 ) )) as 'Total Direct Activites HH:MM'

    ,CONVERT( NVARCHAR( 16 ), 
            FLOOR( ( sum(case
            when
                a.serviceidname  like 'Indirect' and a.[statuscodename] like 'Confirmed' or a.new_approvalstatusname like 'Approved'
            then    
                a.[scheduleddurationminutes]
            end) ) / 60.0 ) ) 
            + N':' + CONVERT( NVARCHAR( 5 ), CONVERT( INTEGER, 
            FLOOR( (sum(case
            when
                a.serviceidname  like 'Indirect'
            then    
                a.[scheduleddurationminutes]
            end)) % 60.0 ) )) as 'Total Indirect Activites HH:MM'


        ,CONVERT( NVARCHAR( 16 ), 
            FLOOR( ( sum(case
            when
                a.[statuscodename] like 'Confirmed' or a.new_approvalstatusname like 'Approved'
            then    
                a.[scheduleddurationminutes]
            end) ) / 60.0 ) ) 
            + N':' + CONVERT( NVARCHAR( 5 ), CONVERT( INTEGER, 
            FLOOR( (sum(case
            when
                a.[statuscodename] like 'Confirmed' or a.new_approvalstatusname like 'Approved'
            then    
                a.[scheduleddurationminutes]
            end)) % 60.0 ) )) as 'Total Direct Activites HH:MM'

        ,Sum(Case 
                when a.[statuscodename] like 'Confirmed' or a.new_approvalstatusname like 'Approved' and a.serviceidname not like 'Indirect'
                then
                    b.new_approvedmileage
                end
            ) as 'Total  Approved Mileage (KMs)'


        ,CONVERT( NVARCHAR( 16 ), 
            FLOOR( ( sum(case
            when
                b.new_expensestatusname like 'Approved'
            then    
                b.new_approvedtravel
            end) ) / 60.0 ) ) 
            + N':' + CONVERT( NVARCHAR( 5 ), CONVERT( INTEGER, 
            FLOOR( (sum(case
            when
                b.new_expensestatusname like 'Approved'
            then    
                b.new_approvedtravel
            end)) % 60.0 ) )) as 'Total Approved Travel Time HH:MM'


        ,count(Case 
                when b.new_expensestatusname like 'Approved' and b.new_expensetypeidname like 'Stipends'
                then
                     b.new_expensetypeidname
                end
            ) As 'Total #Approved Stipends'

from 
    [dbo].[FilteredServiceAppointment] a 
join 
    FilteredSystemUser fu
on a.ownerid = fu.systemuserid
join
    .[dbo].[FilteredNew_expenses] b
on 
    fu.systemuserid = b.new_provider
where 
        a.scheduledstart BETWEEN @Start AND @End 
        AND b.new_serviceactivityid is null
        AND a.siteidname IN (SELECT value FROM dbo.udf_Split(@Office, ','))
        AND a.serviceidname IN (SELECT value FROM dbo.udf_Split(@Servicetype, ',')) 
group by
    a.owneridname
   ,a.[serviceidname] 


END

当我将SP上面的SP调用到SSRS以外的第4列"' Total Direct Activites HH:MM'"这是从上面的代码下面。

,CONVERT( NVARCHAR( 16 ), 
        FLOOR( ( sum(case
        when
            a.serviceidname not like 'Indirect' and a.[statuscodename] like 'Confirmed' or a.new_approvalstatusname like 'Approved'
        then    
            a.[scheduleddurationminutes]
        end) ) / 60.0 ) ) 
        + N':' + CONVERT( NVARCHAR( 5 ), CONVERT( INTEGER, 
        FLOOR( (sum(case
        when
            a.serviceidname not like 'Indirect' 
        then    
            a.[scheduleddurationminutes]
        end)) % 60.0 ) )) as 'Total Direct Activites HH:MM'

一旦我取消注释这部分代码,它就会给我"已经添加了具有相同密钥的项目。"刷新SSRS数据集时出错。

请帮助。

1 个答案:

答案 0 :(得分:2)

您有2列具有相同的确切名称@-webkit-keyframes example { 0% { left: 0px; } 25% { left: 10px ! important; } 100% { left: 0px; } } .seen.animated { position: relative; -webkit-animation-name: example; -webkit-animation-duration: 2s; } 。 SSRS无法解决这个问题。改变一个,然后这应该工作。