需要在T-SQL代码中填充预算余额(BudgetRemaining值)

时间:2019-05-30 02:58:21

标签: tsql accounting balance

我有以下代码(见下文),用于计算期间的 AmountActual AcountBudget 值:07/01/2018-03/31/2019

在此代码中,我还需要填充 AmountBudget 值,但是-在整个会计年度内7/1/18-6/30/19

如何在此代码中实现? 谢谢您的任何建议...

enter 
     DECLARE @FYMonthBOP date = '2018-07-01'
     DECLARE @FYMonthEOP date = '2019-03-31'
     DECLARE @GLProgramGroupSetsWHID int = 8 
     DECLARE @GLProgramGroupsWHID int = -1
     DECLARE @GLProgramsWHID_Groups int = -1

     SELECT        
            trans.GLGroupLevel0Name
          , trans.Ordinal0
          , trans.GLGroupLevel1Name
          , trans.Ordinal1
          , trans.GLGroupLevel2Name
          , trans.Ordinal2
          , trans.GLAccountCode
          , trans.GLAccountName
          , trans.GroupSetName
          , trans.GroupSetNameWHID
          , trans.GroupName
          , trans.GroupNameWHID
          , trans.OrdinalGroupName 
          , trans.Program
          , trans.FQ
          , trans.AmountActual -- these are my main fields I am trying 
          , trans.AmountBudget -- to work with
          , trans.WHIDProgram
          , trans.OrdinalProgram
          , trans.FYMonthNumber
          , trans.FYMonthShortLabel
          , trans.FYQuarterNumber
          , trans.FYNumber
          , trans.FYLabel
          , trans.YearMonthSort
          , trans.BOM
          , trans.EOM
          , trans.DateFrom
          , trans.DateThru

    FROM            
          [Reports].[GLTransMonthlyActualBudget] trans

    WHERE (
          (trans.[EffectiveMonth] BETWEEN @FYMonthBOP AND @FYMonthEOP)
      AND (trans.[GroupSetNameWHID] = @GLProgramGroupSetsWHID)
      AND ((trans.[GroupNameWHID] IN (@GLProgramGroupsWHID)) 
            OR (-1 IN (@GLProgramGroupsWHID)))
      AND ((trans.[WHIDProgram] IN (@GLProgramsWHID_Groups)) 
            OR (-1 IN (@GLProgramsWHID_Groups)))

0 个答案:

没有答案