Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
;
```
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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