none
SSRS using a parameter in a where case statement - is that possible? RRS feed

  • Question

  • Hi all - Hope you are able to help --I need to run a different select statement based on the value of a parameter. Visual studio is not liking how I am formatting it.   I am not sql guru, but I thought it could be done.  Any help would be appreciated. Thank you in advance.

    SELECT           mc.CtrlID,  mc.PrtfID, mc.PrtfTyp, mc.City, mc.STATE, mc.U_O_AND_M, mc.CHBBal,  mc.IRG_Number, mc.PrtfName, mc.LnID,  mc.UPB, mc.UPB_Master_Loan, aa.Prtf_FNMA_FHLMC_Other , aa.ReportingSummar

    FROM             vw_XXX_GIAC mc
    INNER JOIN vw_XXX_InvestorMatrix aa on mc.CtrlID = aa.CtrlID

    WHERE
    case when
    @PortfolioID=1 THEN aa.Prtf_FNMA_FHLMC_Other ='FNMA'
    @PortfolioID=2 THEN aa.Prtf_FNMA_FHLMC_Other ='FHLMC'
    @PortfolioID=3 THEN aa.Reporting Summar ='FLOW'
    END

    Tuesday, July 7, 2015 1:50 PM