billing.billing_type AS last_billing_type,
LAST_VALUE(billing.note) OVER w AS last_billing_note,
MAX(billing.billing_ts) OVER w AS last_billing_ts,
- SUM(COALESCE(billing.amount, 0::numeric)) AS total_owed
+ SUM(COALESCE(billing.amount, 0::numeric)) OVER w AS total_owed
FROM money.billing
WHERE billing.voided IS FALSE
- WINDOW w AS (PARTITION BY billing.xact, billing.billing_type ORDER BY billing.billing_ts ROW BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING);
+ WINDOW w AS (PARTITION BY billing.xact, billing.billing_type ORDER BY billing.billing_ts ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING);
CREATE OR REPLACE VIEW money.transaction_billing_summary AS
SELECT DISTINCT billing.xact,
SUM(COALESCE(billing.amount, 0::numeric)) OVER w AS total_owed
FROM money.billing
WHERE billing.voided IS FALSE
- WINDOW w AS (PARTITION BY billing.xact, billing.billing_type ORDER BY billing.billing_ts ROW BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING);
+ WINDOW w AS (PARTITION BY billing.xact, billing.billing_type ORDER BY billing.billing_ts ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING);
CREATE OR REPLACE VIEW money.open_transaction_billing_summary AS
SELECT DISTINCT xact,
SELECT DISTINCT payment_view.xact,
LAST_VALUE(payment_view.payment_type) OVER w AS last_payment_type,
LAST_VALUE(payment_view.note) OVER w AS last_payment_note,
- MAX(payment_view.payment_ts) OVER w AS last_payment_ts, sum(COALESCE(payment_view.amount, 0::numeric)) AS total_paid
+ MAX(payment_view.payment_ts) OVER w AS last_payment_ts,
+ SUM(COALESCE(payment_view.amount, 0::numeric)) OVER w AS total_paid
FROM money.payment_view
WHERE payment_view.voided IS FALSE
WINDOW w AS (PARTITION BY payment_view.xact ORDER BY payment_view.payment_ts ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING);
SUM(COALESCE(billing.amount, 0::numeric)) OVER w AS total_owed
FROM money.billing
WHERE billing.voided IS FALSE
- WINDOW w AS (PARTITION BY billing.xact, billing.billing_type ORDER BY billing.billing_ts ROW BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING);
+ WINDOW w AS (PARTITION BY billing.xact, billing.billing_type ORDER BY billing.billing_ts ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING);
-- money.open_transaction_payment_summary
SELECT DISTINCT payment_view.xact,
LAST_VALUE(payment_view.payment_type) OVER w AS last_payment_type,
LAST_VALUE(payment_view.note) OVER w AS last_payment_note,
- MAX(payment_view.payment_ts) OVER w AS last_payment_ts, sum(COALESCE(payment_view.amount, 0::numeric)) AS total_paid
+ MAX(payment_view.payment_ts) OVER w AS last_payment_ts,
+ SUM(COALESCE(payment_view.amount, 0::numeric)) OVER w AS total_paid
FROM money.payment_view
WHERE payment_view.voided IS FALSE
WINDOW w AS (PARTITION BY payment_view.xact ORDER BY payment_view.payment_ts ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING);
billing.billing_type AS last_billing_type,
LAST_VALUE(billing.note) OVER w AS last_billing_note,
MAX(billing.billing_ts) OVER w AS last_billing_ts,
- SUM(COALESCE(billing.amount, 0::numeric)) AS total_owed
+ SUM(COALESCE(billing.amount, 0::numeric)) OVER w AS total_owed
FROM money.billing
WHERE billing.voided IS FALSE
- WINDOW w AS (PARTITION BY billing.xact, billing.billing_type ORDER BY billing.billing_ts ROW BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING);
+ WINDOW w AS (PARTITION BY billing.xact, billing.billing_type ORDER BY billing.billing_ts ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING);
-- money.transaction_billing_with_void_summary