summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2020-02-01 01:33:57 -0500
committerJesse Luehrs <doy@tozt.net>2020-02-01 01:33:57 -0500
commit66ad8ec5d006e9ea120213f39493ea5dc4a45019 (patch)
tree668cea69ddebd673d123a711e0c65765de1001ea
parentb54b50d7a300917e177e3fafce975b72bf815c9f (diff)
downloadmetabase-utils-66ad8ec5d006e9ea120213f39493ea5dc4a45019.tar.gz
metabase-utils-66ad8ec5d006e9ea120213f39493ea5dc4a45019.zip
add another view
-rw-r--r--data/denorm.sql34
1 files changed, 34 insertions, 0 deletions
diff --git a/data/denorm.sql b/data/denorm.sql
index 915df09..fd0e273 100644
--- a/data/denorm.sql
+++ b/data/denorm.sql
@@ -1,3 +1,4 @@
+DROP VIEW IF EXISTS spending;
DROP VIEW IF EXISTS future_transactions;
DROP VIEW IF EXISTS denorm_scheduled_transactions;
DROP VIEW IF EXISTS denorm_transactions;
@@ -316,3 +317,36 @@ CREATE VIEW future_transactions AS (
WHERE
date <= CURRENT_DATE + interval '2 years'
);
+
+CREATE VIEW spending AS (
+ SELECT
+ id,
+ subtransaction_id,
+ date,
+ amount,
+ memo,
+ cleared,
+ approved,
+ flag_color,
+ account_id,
+ account,
+ payee_id,
+ payee,
+ category_group_id,
+ category_group,
+ category_id,
+ category
+ FROM
+ denorm_transactions LEFT JOIN categories ON (
+ denorm_transactions.category_id = categories.id
+ )
+ WHERE
+ amount < 0 AND
+ NOT categories.hidden AND
+ transfer_account_id IS NULL AND
+ category != 'Retirement' and
+ category != 'Income Tax' and
+ category != 'Donations' and
+ category != 'Family' and
+ category != 'Reimbursables'
+);