title: SQL Query to Calculate Monthly Budget
body: <pre><code>CREATE TABLE [dbo].[EmployeeMonthlyBudget]
  (
      [Name] [NVARCHAR](50) NULL,
      [Budget_Day] [MONEY] NULL,
      [DateCreated] [DATETIME] NULL,
      [DateDeleted] [DATETIME] NULL
  ) 
  
  INSERT INTO [dbo].[EmployeeMonthlyBudget] ([Name], [Budget_Day], [DateCreated], [DateDeleted]) 
  VALUES (N'SAM', 20.0000, CAST(N'2018-01-01T00:00:00.000' AS DateTime), CAST(N'2018-10-01T00:00:00.000' AS DateTime)),
         (N'ROB', 10.0000, CAST(N'2018-01-01T00:00:00.000' AS DateTime), NULL),
         (N'TAM', 5.0000, CAST(N'2018-01-01T00:00:00.000' AS DateTime), CAST(N'2018-05-01T00:00:00.000' AS DateTime)),
         (N'TAN', 100.0000, CAST(N'2018-01-01T00:00:00.000' AS DateTime), NULL)   
  </code></pre>
  
  <p>The above is the table structure we had to calculate monthly budget.</p>
  
  <p>We are displaying the bar graph for each name how their monthly budget is.
  Suppose if we take Sam his budget for Jan is 620 and Feb is 580 and so on, So we need to calculate the budget for each month until <code>DateDeleted</code> has value</p>
  
  <p>We are able to calculate the budget per month for each Employee Name, but unable 
  to figure out how to calculate them for consecutive months.</p>
  
  <p>Please, anyone, help me on this
  How to write SQL for the above approach.
  Please sample  table data</p>
  
  <p><img src="https://i.imgur.com/wy61coe.png" alt="a busy cat"></p>