Skip to content

Instantly share code, notes, and snippets.

View tobiascoetzee's full-sized avatar

Tobias Coetzee tobiascoetzee

View GitHub Profile
@tobiascoetzee
tobiascoetzee / dayproducttotal-window.sql
Created June 2, 2018 01:02
SQL query that returns a list of all the products sold with a running total for each product and each day plus a total for each day and product using Windows over function
SET NOCOUNT ON;
SELECT
ProductID
,ModifiedDate
,UnitPrice
,SUM(UnitPrice) OVER (
PARTITION BY ModifiedDate
ORDER BY ProductID, ModifiedDate, SalesOrderID
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) ASModifiedDateBalance
@tobiascoetzee
tobiascoetzee / dayproducttotal.sql
Last active June 2, 2018 00:56
SQL query that returns a list of all the products sold with a running total for each product and each day plus a total for each day and product.
SET NOCOUNT ON;
DECLARE @Balances AS TABLE
(
ProductId INT
,ModifiedDate DATETIME
,UnitPrice MONEY
,ModifiedDateBalance MONEY
,ProductIdBalance MONEY
,ModifiedDateTotal MONEY
class ValidationChecker():
def __init__(self, validationContext, validationsFile, validationsModule):
self.Context = validationContext
self.Errors = {}
self.__validationsTree = self.__LoadFile(validationsFile)
self.__module = __import__(validationsModule)
def __LoadFile(self, validationsFile):
base = ''