ssrs中的错误。已添加具有相同键的项目

时间:2018-02-27 05:54:00

标签: reporting-services ssrs-2008

我正在SSRS中报告错误即将发生。 这是我认为与我的数据集有关。我想制作多选项参数报告。所以我的查询是。

 IF @QueryParameterType=1
  (
     SELECT
              cast(fddateofissue as date) As IssueDate
            , cast(fddateofcash as  date) as CashDate
            , Substring(fsreckey,1,3)[DIVISION]
            , FNGROUP-100[GROUP]
            , FNCYCLE[CYCLE]
            , SUBSTRING(FSRECKEY,4,4)[LEDGER]
            , FNACCNO[ACCNO]
            , FSNAME[NAME]
            , FSADDRESS[ADDRESS]
            , fsVillage [VILLAGE]
            , fsFeederCode [CIN DATA]
            , fnSecurityAmount [ACD AMOUNT]
            , fnConnLoad[LOAD]
            , fnMtrMultiplier[MTR MULTIPLIER]
            , fnMtrPhase [MTR PHASE]
            , fnCurrReading[CURRENT READING]
            , fnPrevReading[PREVIOUS READING]
            , fnBillUnits[UNIT BILLED]
            , fnAvgUnits [AVERAGE UNIT]
            , fnBillPeriod [BILL PERIOD]
            , fnArrSOP +fnArrFSA +fnArrED +fnArrMCT +fnArrSURC[ARREAR        TOTAL]
            , fnPaidTotal[PAID TOTAL]
            , fdPaidDate
            , fnCurrSOP[CURRENT SOP]
            , fnCurrFSA[CURRENT FSA]
            , fnCurrED[CURRENT ED]
            , fnCurrMCT[CURRENT MCT]
            , fnNetCapPenalty[CAP PENALTY]
            , fnNetMdiPenalty[MDI]
            , fnFixcharges[FIXED CHARGES]
            , fnChrSOP +fnChrFSA +fnChrED +fnChrMCT[CHARGES]
            , fsChrBNO[BNO]
            , fnChrPNO [PNO]
            , fnAlwSOP+fnAlwFSA +fnAlwED +fnAlwMCT[ALLOWANCE]
            , fsAlwBNO [BNO]
            , fnAlwPNO [PNO]
            , fnNetMtrRent[MTR RENT]
            , fnNetTotal[NET TOTAL]
            , fnNetSURC[NET SURCHARGE]
            , fnNetGross[GROSS TOTAL]
            , CASE
                       WHEN fnflgPDCO>2
                                THEN 'PDCO'
                                ELSE 'LIVE'
              END 'STATUS'
            , fsCurrMtrStatus
            , fnMdiReading
            , fnNetMdiPenalty


          FROM
              (


                     SELECT *
                          , NULL AS FDBACKUPDATE
                          , 109  AS FANSESSIONCODE
                     FROM
                            tblLedger
                     UNION ALL
                     SELECT *
                          , NULL AS FDBACKUPDATE
                          , 109  AS FANSESSIONCODE
                     FROM
                            tblPREVIOUSLEDGER
                     UNION ALL
                     SELECT *
                     FROM
                            UH_BACKUP..tblbackupledger

              )
              AS T
              --WHERE T.FSSUBDIV=102 AND T.FNGROUP=102 AND T.FNCATEGORY=6                        and fsledger=2829  and fnaccno =2
     WHERE
              T.FSSUBDIV      =@subdiv
              AND T.FNGROUP   =@group
              AND T.FNCATEGORY=@category
              and t.fsledger  =@ledger
              and t.fnaccno   =@accno
              and t.fddateofissue between @issueDate1 and @issueDate2




            )

             else
         if @QueryParameterType=2
          (
           SELECT
              cast(fddateofissue as date) As IssueDate
            , cast(fddateofcash as  date) as CashDate
            , Substring(fsreckey,1,3)[DIVISION]
            , FNGROUP-100[GROUP]
            , FNCYCLE[CYCLE]
            , SUBSTRING(FSRECKEY,4,4)[LEDGER]
            , FNACCNO[ACCNO]
            , FSNAME[NAME]
            , FSADDRESS[ADDRESS]
            , fsVillage [VILLAGE]
            , fsFeederCode [CIN DATA]
            , fnSecurityAmount [ACD AMOUNT]
            , fnConnLoad[LOAD]
            , fnMtrMultiplier[MTR MULTIPLIER]
            , fnMtrPhase [MTR PHASE]
            , fnCurrReading[CURRENT READING]
            , fnPrevReading[PREVIOUS READING]
            , fnBillUnits[UNIT BILLED]
            , fnAvgUnits [AVERAGE UNIT]
            , fnBillPeriod [BILL PERIOD]
            , fnArrSOP +fnArrFSA +fnArrED +fnArrMCT +fnArrSURC[ARREAR TOTAL]
            , fnPaidTotal[PAID TOTAL]
            , fdPaidDate
            , fnCurrSOP[CURRENT SOP]
            , fnCurrFSA[CURRENT FSA]
            , fnCurrED[CURRENT ED]
            , fnCurrMCT[CURRENT MCT]
            , fnNetCapPenalty[CAP PENALTY]
            , fnNetMdiPenalty[MDI]
            , fnFixcharges[FIXED CHARGES]
            , fnChrSOP +fnChrFSA +fnChrED +fnChrMCT[CHARGES]
            , fsChrBNO[BNO]
            , fnChrPNO [PNO]
            , fnAlwSOP+fnAlwFSA +fnAlwED +fnAlwMCT[ALLOWANCE]
            , fsAlwBNO [BNO]
            , fnAlwPNO [PNO]
            , fnNetMtrRent[MTR RENT]
            , fnNetTotal[NET TOTAL]
            , fnNetSURC[NET SURCHARGE]
            , fnNetGross[GROSS TOTAL]
            , CASE
                       WHEN fnflgPDCO>2
                                THEN 'PDCO'
                                ELSE 'LIVE'
              END 'STATUS'
            , fsCurrMtrStatus
            , fnMdiReading
            , fnNetMdiPenalty


     FROM
              (


                     SELECT *
                          , NULL AS FDBACKUPDATE
                          , 109  AS FANSESSIONCODE
                     FROM
                            tblLedger
                     UNION ALL
                     SELECT *
                          , NULL AS FDBACKUPDATE
                          , 109  AS FANSESSIONCODE
                     FROM
                            tblPREVIOUSLEDGER
                     UNION ALL
                     SELECT *
                     FROM
                            UH_BACKUP..tblbackupledger

              )
              AS T
              --WHERE T.FSSUBDIV=102 AND T.FNGROUP=102 AND T.FNCATEGORY=6 and fsledger=2829  and fnaccno =2
     WHERE
              T.FSSUBDIV      =@subdiv
              AND T.FNGROUP   =@group
              AND T.FNCATEGORY=@category
              and t.fsledger  =@ledger
              and t.fnaccno   =@accno




           )

它在查询设计器中工作正常但是当我保存这个数据集时它会给出

  

已添加具有相同键的项目。

我想知道查询是否有任何问题。

1 个答案:

答案 0 :(得分:4)

此错误通常是由于具有相同别名的字段,在您的查询中似乎有2个BNO和2个PNO列。可能还有其他人,检查所有列并确保它们都有不同的别名。