QUERY PLAN
Aggregate (cost=11.34..11.35 rows=1 width=8)
-> Sort (cost=11.30..11.30 rows=3 width=337)
Sort Key: sub.created_at DESC
-> Subquery Scan on sub (cost=0.00..11.27 rows=3 width=337)
-> Append (cost=0.00..11.24 rows=3 width=337)
-> Subquery Scan on "*SELECT* 1" (cost=0.00..3.90 rows=1 width=191)
-> Seq Scan on tbl_erp_other_payment_tickets r (cost=0.00..3.89 rows=1 width=189)
Filter: ((status = 2) AND (supplier_id = 431) AND ((amount - settle_amount) > '0'::numeric))
-> Seq Scan on tbl_erp_cost_tickets r_1 (cost=0.00..4.65 rows=1 width=202)
Filter: ((status = 2) AND (supplier_id = 431) AND ((amount - settle_amount) > '0'::numeric))
-> Subquery Scan on "*SELECT* 3" (cost=0.00..2.68 rows=1 width=213)
-> Seq Scan on tbl_erp_other_collect_tickets r_2 (cost=0.00..2.67 rows=1 width=211)
Filter: ((bank_settle_at IS NULL) AND (status = 2) AND (supplier_id = 431))