| Sort (cost=482.19..482.21 rows=9 width=165) |
| Sort Key: scpcrd.remind_date DESC |
| -> Nested Loop (cost=102.31..482.05 rows=9 width=165) |
| -> Seq Scan on tbl_sales_contract_payment_collection_remind_dates scpcrd (cost=0.00..18.38 rows=3 width=93) |
| Filter: (contract_id = 8) |
| -> Materialize (cost=102.31..102.37 rows=3 width=36) |
| -> Subquery Scan on sc (cost=102.31..102.36 rows=3 width=36) |
| -> Group (cost=102.31..102.33 rows=3 width=1126) |
| Group Key: sc_1.id, (sum("*SELECT* 1".amount)) |
| -> Sort (cost=102.31..102.31 rows=3 width=36) |
| Sort Key: (sum("*SELECT* 1".amount)) |
| -> Nested Loop Left Join (cost=0.14..102.28 rows=3 width=36) |
| Join Filter: ("*SELECT* 1".contract_id = sc_1.id) |
| -> Index Only Scan using tbl_sales_contracts_pkey on tbl_sales_contracts sc_1 (cost=0.14..8.16 rows=1 width=4) |
| Index Cond: (id = 8) |
| -> GroupAggregate (cost=0.00..94.07 rows=3 width=36) |
| Group Key: "*SELECT* 1".contract_id |
| -> Append (cost=0.00..93.99 rows=3 width=124) |
| -> Subquery Scan on "*SELECT* 1" (cost=0.00..31.12 rows=1 width=124) |
| -> Nested Loop (cost=0.00..31.10 rows=1 width=120) |
| Join Filter: (r.erp_collect_ticket_id = t.id) |
| -> Seq Scan on tbl_erp_collect_ticket_settles r (cost=0.00..18.75 rows=3 width=44) |
| Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = 8)) |
| -> Materialize (cost=0.00..12.26 rows=2 width=52) |
| -> Seq Scan on tbl_erp_collect_tickets t (cost=0.00..12.25 rows=2 width=52) |
| Filter: (status = ANY ('{2,5}'::integer[])) |
| -> Nested Loop (cost=0.00..31.81 rows=1 width=124) |
| Join Filter: (r_1.erp_cash_cost_ticket_id = t_1.id) |
| -> Seq Scan on tbl_erp_cash_cost_tickets t_1 (cost=0.00..12.38 rows=1 width=48) |
| Filter: (is_payment_settle AND (status = ANY ('{2,5}'::integer[]))) |
| -> Seq Scan on tbl_erp_cash_cost_ticket_sales_contract_settles r_1 (cost=0.00..19.38 rows=4 width=44) |
| Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = 8)) |
| -> Nested Loop (cost=0.00..31.05 rows=1 width=124) |
| Join Filter: (r_2.erp_payment_ticket_id = t_2.id) |
| -> Seq Scan on tbl_erp_payment_tickets t_2 (cost=0.00..12.25 rows=1 width=48) |
| Filter: (is_payment_settle AND (status = ANY ('{2,5}'::integer[]))) |
| -> Seq Scan on tbl_erp_payment_ticket_settles r_2 (cost=0.00..18.75 rows=3 width=44) |
| Filter: ((sales_contract_id IS NOT NULL) AND (sales_contract_id = 8)) |
| SubPlan 1 |
| -> Aggregate (cost=20.05..20.07 rows=1 width=32) |
| -> Seq Scan on tbl_sales_contract_payment_collection_remind_dates scpcrdsub (cost=0.00..20.05 rows=1 width=32) |
| Filter: ((remind_date <= scpcrd.remind_date) AND (contract_id = scpcrd.contract_id)) |
| SubPlan 2 |
| -> Aggregate (cost=20.05..20.07 rows=1 width=32) |
| -> Seq Scan on tbl_sales_contract_payment_collection_remind_dates scpcrdsub_1 (cost=0.00..20.05 rows=1 width=32) |
| Filter: ((remind_date <= scpcrd.remind_date) AND (contract_id = scpcrd.contract_id)) |