|
Last change
on this file since 42da64d was 42da64d, checked in by Andrej <asumanovski@…>, 8 weeks ago |
|
Fixed auth issue
|
-
Property mode
set to
100644
|
|
File size:
909 bytes
|
| Line | |
|---|
| 1 | -- View: calculate allocation amounts per finance category for the current month
|
|---|
| 2 | CREATE OR REPLACE VIEW trekr.vw_finance_allocations_current_month AS
|
|---|
| 3 | SELECT
|
|---|
| 4 | f.user_id,
|
|---|
| 5 | fm.total_earned_this_month,
|
|---|
| 6 | f.spending_budget,
|
|---|
| 7 | f.saving_budget,
|
|---|
| 8 | f.investing_budget,
|
|---|
| 9 | f.donation_budget,
|
|---|
| 10 | f.credit,
|
|---|
| 11 | ROUND((COALESCE(f.spending_budget,0) / 100.0) * fm.total_earned_this_month, 2) AS spending_amount,
|
|---|
| 12 | ROUND((COALESCE(f.saving_budget,0) / 100.0) * fm.total_earned_this_month, 2) AS saving_amount,
|
|---|
| 13 | ROUND((COALESCE(f.investing_budget,0) / 100.0) * fm.total_earned_this_month, 2) AS investing_amount,
|
|---|
| 14 | ROUND((COALESCE(f.donation_budget,0) / 100.0) * fm.total_earned_this_month, 2) AS donation_amount,
|
|---|
| 15 | ROUND((COALESCE(f.credit,0) / 100.0) * fm.total_earned_this_month, 2) AS credit_amount
|
|---|
| 16 | FROM trekr.finance_users f
|
|---|
| 17 | LEFT JOIN trekr.vw_finance_current_month fm ON fm.user_id = f.user_id;
|
|---|
| 18 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.