QUERY PLAN
Aggregate (cost=9.43..9.44 rows=1 width=32)
-> Nested Loop (cost=0.28..9.43 rows=1 width=6)
-> Seq Scan on tbl_erp_payment_ticket_payments r (cost=0.00..1.12 rows=1 width=10)
Filter: (erp_advance_payment_ticket_id IS NOT NULL)
-> Index Scan using tbl_erp_payment_tickets_pkey on tbl_erp_payment_tickets t (cost=0.28..8.30 rows=1 width=4)
Index Cond: (id = r.erp_payment_ticket_id)
Filter: ((created_at <= '2026-06-30 23:59:59+08'::timestamp with time zone) AND (status = 2))