diff --git a/decomposed/models/ExampleDWH/EXAMPLEDWH.model.xml b/decomposed/models/ExampleDWH/EXAMPLEDWH.model.xml new file mode 100644 index 0000000..4dd2b81 --- /dev/null +++ b/decomposed/models/ExampleDWH/EXAMPLEDWH.model.xml @@ -0,0 +1,344 @@ + + + + + + + + + Aggregate the total of sales order to customer level. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Business rule to get the last sales order per customer. We use a custom business rule here, since we can't model it using the standard filter rule. + + + + + + + + + + + + + + + + + + + + + + WITH SalesOrdersCTE AS ( + SELECT + Id, + OrderDate, + OrderNumber, + CustomerId, + TotalAmount, + -- Create a row-number for the order per customer, this way we can filter on the last order. + ROW_NUMBER() OVER (PARTITION BY CustomerId ORDER BY OrderDate DESC) AS CustomerOrderRowNumber + FROM SalesOrder + ) + SELECT + Id, + OrderDate, + OrderNumber, + CustomerId, + TotalAmount + FROM SalesOrdersCTE + -- Only the last SalesOrder record per customer. + WHERE CustomerOrderRowNumber = 1 + + + + Example which only expected the last SalesOrder of a single Customer. + + + + + + + + + + + Calculate the age of order + + + + + + DATEDIFF(DAY, @ORDER_DATE, @CURRENT_DATE) AS ORDER_AGE_IN_DAYS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Merge the firstname and lastname of a customer. + + + + + + FIRST_NAME || ' ' || LAST_NAME AS FULL_NAME + + + + + + + + + + + + + + Only include records where the country is the Netherlands. + + + + @COUNTRY_CODE = 'NL' + + + When the country is equal to 'NL', the record should be included. + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/decomposed/models/ExampleSource/EXAMPLESOURCE.model.xml b/decomposed/models/ExampleSource/EXAMPLESOURCE.model.xml index 93536c4..33848ac 100644 --- a/decomposed/models/ExampleSource/EXAMPLESOURCE.model.xml +++ b/decomposed/models/ExampleSource/EXAMPLESOURCE.model.xml @@ -1,18 +1,19 @@ - + - - - - - + + + + + + - + - + @@ -21,21 +22,20 @@ - + - + - - - - - - + + + + + - + - + @@ -44,6 +44,7 @@ - + - \ No newline at end of file + + \ No newline at end of file diff --git a/decomposed/models/Reference/REFERENCE.model.xml b/decomposed/models/Reference/REFERENCE.model.xml index 3144e86..cfba9ef 100644 --- a/decomposed/models/Reference/REFERENCE.model.xml +++ b/decomposed/models/Reference/REFERENCE.model.xml @@ -3,12 +3,12 @@ - - - + + + - +