| Actor | Fragment | Worker | State |
|---|---|---|---|
| 739992 | 61751 | 51 | running |
| 739993 | 61751 | 51 | running |
| 739994 | 61750 | 51 | running |
| 739995 | 61750 | 51 | running |
| 739996 | 61752 | 51 | running |
| 739997 | 61752 | 51 | running |
| 739998 | 61753 | 51 | running |
| 739999 | 61753 | 51 | running |
| 740000 | 61754 | 51 | running |
| 740001 | 61754 | 51 | running |
| 740002 | 61755 | 51 | running |
| 740003 | 61755 | 51 | running |
CREATE MATERIALIZED VIEW opportunity.account_balance_delta_mv AS
SELECT
oa.account_id,
b.dim_balance_date,
b.currency_code,
b.market_value,
prev.market_value AS prev_market_value
FROM insights.position_summary_mv AS b
JOIN insights.position_summary_mv AS prev
ON prev.account_group_id = b.account_group_id
AND prev.position_type = b.position_type
AND prev.currency_code = b.currency_code
AND prev.dim_balance_date = b.dim_balance_date - 1
JOIN insights.open_accounts_mv AS oa
ON b.account_group_id = 'account_group_' || MD5(CAST((
oa.account_id || 'all'
) AS BYTEA))
JOIN olap.product_types_dm AS pt
ON pt.product_type_id = oa.product_type_id
WHERE
b.source_entity_type = 'account'
AND b.position_type = 'POSITION'
AND pt.type = 'INVESTMENT'
AND prev.market_value > 0
AND CAST(b.dim_balance_date AS TIMESTAMPTZ) >= CURRENT_TIMESTAMP - INTERVAL '30 DAYS'