QUERY PLAN
Aggregate (cost=25.53..25.54 rows=1 width=8)
-> Sort (cost=25.30..25.34 rows=15 width=285)
Sort Key: sub.created_at
-> Subquery Scan on sub (cost=0.00..25.01 rows=15 width=285)
-> Append (cost=0.00..24.86 rows=15 width=285)
-> Seq Scan on tbl_sales_contracts r (cost=0.00..10.96 rows=12 width=527)
Filter: (build_by_project AND (erp_un_settle_amount > '0'::numeric))
-> Subquery Scan on "*SELECT* 2" (cost=0.00..12.65 rows=1 width=335)
-> Seq Scan on tbl_erp_other_collect_tickets r_1 (cost=0.00..12.63 rows=1 width=333)
Filter: ((status = 2) AND ((amount - settle_amount) > '0'::numeric))
-> Subquery Scan on "*SELECT* 3" (cost=0.00..1.12 rows=2 width=296)
-> Seq Scan on tbl_purchase_contracts r_2 (cost=0.00..1.10 rows=2 width=294)
Filter: ((NOT is_draft) AND (NOT is_refuse) AND (erp_un_settle_amount < '0'::numeric))