Comment 1 for bug 1206936

Revision history for this message
Chris Sharp (chrissharp123) wrote :

Thank you to Mike Rylander who proposed this solution to the problem with that particular view:

CREATE OR REPLACE VIEW money.transaction_billing_summary AS
    SELECT DISTINCT xact,
        LAST_VALUE(billing_type) OVER w AS last_billing_type,
        LAST_VALUE(note) OVER w AS last_billing_note,
        MAX(billing_ts) OVER w AS last_billing_ts,
        SUM(COALESCE(amount,0)) OVER w AS total_owed
      FROM money.billing
      WHERE voided IS FALSE
      WINDOW w AS (PARTITION BY xact ORDER BY billing_ts ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING);

As he mentioned, there are many others to convert to using window functions. I have identified a list:

-- money.billable_xact_summary_new
-- money.billable_xact_with_void_summary
-- money.open_transaction_billing_summary
-- money.open_transaction_billing_type_summary
-- money.open_transaction_payment_summary
-- money.transaction_billing_type_summary
-- money.transaction_billing_with_void_summary
-- money.transaction_payment_summary
-- money.transaction_payment_with_void_summary

I'm not sure how involved changing all of those would be, but it sounds like project.