QUERY PLAN
Aggregate (cost=155.15..155.16 rows=1 width=8)
-> Sort (cost=154.22..154.38 rows=62 width=285)
Sort Key: sub.created_at
-> Subquery Scan on sub (cost=0.00..152.38 rows=62 width=285)
-> Append (cost=0.00..151.75 rows=62 width=285)
-> Seq Scan on tbl_sales_contracts r (cost=0.00..73.19 rows=49 width=175)
Filter: (build_by_project AND (erp_un_settle_amount > '0'::numeric))
-> Subquery Scan on "*SELECT* 2" (cost=0.00..2.94 rows=12 width=194)
-> Seq Scan on tbl_erp_other_collect_tickets r_1 (cost=0.00..2.79 rows=12 width=192)
Filter: ((status = 2) AND ((amount - settle_amount) > '0'::numeric))
-> Subquery Scan on "*SELECT* 3" (cost=0.00..75.14 rows=1 width=249)
-> Seq Scan on tbl_purchase_contracts r_2 (cost=0.00..75.12 rows=1 width=247)
Filter: ((NOT is_draft) AND (NOT is_refuse) AND (erp_un_settle_amount < '0'::numeric))