database redesign

This commit is contained in:
Peter Wood
2022-08-02 06:12:02 -04:00
parent 27e7c7829c
commit 477bfe3cfb
5 changed files with 12 additions and 10 deletions

2
.gitignore vendored
View File

@@ -1,2 +1,4 @@
.vs/* .vs/*
budget.sqlproj budget.sqlproj
Load BUDGET_DETAIL.sql
budget queries.sql

BIN
holidays.sql Normal file

Binary file not shown.

View File

@@ -9,7 +9,7 @@ begin
set @yr = isnull(@yr, year(getdate())) set @yr = isnull(@yr, year(getdate()))
set @mo = isnull(@mo, month(getdate())) set @mo = isnull(@mo, month(getdate()))
select Id, TrxDate, TrxDate_ISO8601, TrxDescription, TrxAmount, RunningBal select TrxId, TrxDate, TrxDate_ISO8601, TrxDescription, TrxAmount, RunningBal
from dbo.vw_BudgetRunningBalance from dbo.vw_BudgetRunningBalance
where where
YEAR(TrxDate) = @yr YEAR(TrxDate) = @yr

View File

@@ -1,9 +1,9 @@
use Leo use Leo
go go
create view dbo.vw_BUDGET_RUNNING_BAL alter view dbo.vw_BudgetRunningBalance
as as
select select
BDT_DATE, BDT_DESCRIPTION, BDT_AMOUNT TrxId, TrxDate, TrxDate_ISO8601=convert(datetime, TrxDate, 126), TrxDescription, TrxAmount
, sum(BDT_AMOUNT) over(order by BDT_DATE, BDT_AMOUNT desc rows unbounded preceding) RUNNING_BAL , sum(TrxAmount) over(order by TrxDate, TrxAmount desc rows unbounded preceding) RunningBal
from dbo.BUDGET_DETAIL from dbo.BUDGET_DETAIL

View File

@@ -1,8 +1,8 @@
use Leo use Leo
go go
create view dbo.vw_CURR_MONTH_BUDGET alter view dbo.vw_CurrentMonthBudget
as as
select * select *
from dbo.vw_BUDGET_RUNNING_BAL from dbo.vw_BudgetRunningBalance
where BDT_DATE between dateadd(DAY, 1, EOMONTH(getDate(), -1)) and eomonth(getDate()) where TrxDate between dateadd(DAY, 1, EOMONTH(getDate(), -1)) and eomonth(getDate())