| Aggregate (cost=172.97..172.98 rows=1 width=32) |
| -> Nested Loop (cost=157.20..172.97 rows=1 width=5) |
| -> Nested Loop (cost=157.05..169.58 rows=1 width=9) |
| Join Filter: (((sum(r_1.amount)) + (sum(r.amount))) < t.amount) |
| -> Merge Join (cost=156.91..168.33 rows=1 width=85) |
| Merge Cond: (dt1.object_id = r_1.erp_cost_ticket_id) |
| -> Nested Loop (cost=38.95..50.26 rows=1 width=49) |
| -> GroupAggregate (cost=38.66..38.68 rows=1 width=36) |
| Group Key: r.erp_cost_ticket_id |
| -> Sort (cost=38.66..38.66 rows=1 width=10) |
| Sort Key: r.erp_cost_ticket_id |
| -> Nested Loop (cost=0.28..38.65 rows=1 width=10) |
| -> Seq Scan on tbl_erp_collect_ticket_payments r (cost=0.00..1.06 rows=5 width=14) |
| Filter: (erp_cost_ticket_id IS NOT NULL) |
| -> Index Scan using tbl_erp_collect_tickets_pkey on tbl_erp_collect_tickets t_1 (cost=0.28..7.50 rows=1 width=4) |
| Index Cond: (id = r.erp_collect_ticket_id) |
| Filter: ((bank_settle_at <= '2026-06-30 23:59:59+08'::timestamp with time zone) AND (status = 2)) |
| -> Index Scan using tbl_term_taxonomy_relationships_object_id_term_id_idx on tbl_term_taxonomy_relationships dt1 (cost=0.29..11.56 rows=1 width=13) |
| Index Cond: ((object_id = r.erp_cost_ticket_id) AND (term_id = 18)) |
| Filter: (object_type = 9) |
| -> GroupAggregate (cost=117.96..118.02 rows=3 width=36) |
| Group Key: r_1.erp_cost_ticket_id |
| -> Sort (cost=117.96..117.97 rows=3 width=10) |
| Sort Key: r_1.erp_cost_ticket_id |
| -> Hash Join (cost=40.04..117.94 rows=3 width=10) |
| Hash Cond: (t_2.id = r_1.erp_payment_ticket_id) |
| -> Seq Scan on tbl_erp_payment_tickets t_2 (cost=0.00..74.31 rows=259 width=4) |
| Filter: ((bank_settle_at <= '2026-06-30 23:59:59+08'::timestamp with time zone) AND (status = 2)) |
| -> Hash (cost=39.65..39.65 rows=31 width=14) |
| -> Seq Scan on tbl_erp_payment_ticket_settles r_1 (cost=0.00..39.65 rows=31 width=14) |
| Filter: (erp_cost_ticket_id IS NOT NULL) |
| -> Index Scan using tbl_erp_cost_tickets_pkey on tbl_erp_cost_tickets t (cost=0.14..1.23 rows=1 width=9) |
| Index Cond: (id = dt1.object_id) |
| Filter: ((verify_at <= '2026-06-30 23:59:59+08'::timestamp with time zone) AND (status = 2)) |
| -> Index Scan using tbl_term_taxonomies_pkey on tbl_term_taxonomies tt (cost=0.15..1.77 rows=1 width=4) |
| Index Cond: (id = dt1.taxonomy_id) |
| Filter: ((serial_no)::text = '221106'::text) |