Skip to content

Commit fd2d0de

Browse files
Add example for projected spend (#90)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 13a0705 commit fd2d0de

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,31 @@ ORDER BY
170170
, payee
171171
;
172172
```
173+
174+
To count the spend for a category (ex: "Apps") between this month and the next 11 months (inclusive):
175+
176+
```sql
177+
SELECT
178+
budget_id
179+
, SUM(amount_major) AS amount_major
180+
FROM (
181+
SELECT
182+
budget_id
183+
, amount_major
184+
FROM flat_transactions
185+
WHERE
186+
NOT deleted
187+
AND category_name = 'Apps'
188+
AND SUBSTR(`date`, 1, 7) = SUBSTR(DATE(), 1, 7)
189+
UNION ALL
190+
SELECT
191+
budget_id
192+
, amount_major
193+
FROM scheduled_flat_transactions
194+
WHERE
195+
NOT deleted
196+
AND category_name = 'Apps'
197+
AND SUBSTR(date_next, 1, 7) < SUBSTR(DATE('now', '+1 year'), 1, 7)
198+
)
199+
;
200+
```

pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ extend-select = [
3434
line_position = "leading"
3535
spacing_before = "touch"
3636

37+
[tool.sqlfluff.rules.capitalisation.functions]
38+
extended_capitalisation_policy = 'upper'
39+
40+
[tool.sqlfluff.rules.capitalisation.identifiers]
41+
extended_capitalisation_policy = 'lower'
42+
43+
[tool.sqlfluff.rules.capitalisation.keywords]
44+
capitalisation_policy = 'upper'
45+
3746
[tool.sqlfluff.rules.convention.terminator]
3847
multiline_newline = true
3948
require_final_semicolon = true

0 commit comments

Comments
 (0)