diff --git a/README.md b/README.md index feb6c8c..1f1592c 100644 --- a/README.md +++ b/README.md @@ -170,3 +170,31 @@ ORDER BY , payee ; ``` + +To count the spend for a category (ex: "Apps") between this month and the next 11 months (inclusive): + +```sql +SELECT + budget_id + , SUM(amount_major) AS amount_major +FROM ( + SELECT + budget_id + , amount_major + FROM flat_transactions + WHERE + NOT deleted + AND category_name = 'Apps' + AND SUBSTR(`date`, 1, 7) = SUBSTR(DATE(), 1, 7) + UNION ALL + SELECT + budget_id + , amount_major + FROM scheduled_flat_transactions + WHERE + NOT deleted + AND category_name = 'Apps' + AND SUBSTR(date_next, 1, 7) < SUBSTR(DATE('now', '+1 year'), 1, 7) +) +; +``` diff --git a/pyproject.toml b/pyproject.toml index 152a079..42d9c78 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,15 @@ extend-select = [ line_position = "leading" spacing_before = "touch" +[tool.sqlfluff.rules.capitalisation.functions] +extended_capitalisation_policy = 'upper' + +[tool.sqlfluff.rules.capitalisation.identifiers] +extended_capitalisation_policy = 'lower' + +[tool.sqlfluff.rules.capitalisation.keywords] +capitalisation_policy = 'upper' + [tool.sqlfluff.rules.convention.terminator] multiline_newline = true require_final_semicolon = true