Aggregate (cost=531.49..531.50 rows=1 width=8) |
-> Sort (cost=507.76..511.71 rows=1582 width=726) |
Sort Key: (CASE WHEN (p.erp_sales_amount <> '0'::numeric) THEN (p.erp_profit_amount / p.erp_sales_amount) ELSE NULL::numeric END), p.updated_at DESC |
-> Subquery Scan on p (cost=360.41..423.69 rows=1582 width=726) |
-> HashAggregate (cost=360.41..399.96 rows=1582 width=698) |
Group Key: p_1.id, r.user_id, (sum(r.pct)) |
-> Hash Left Join (cost=313.33..336.68 rows=1582 width=120) |
Hash Cond: (p_1.id = o.project_id) |
-> Hash Right Join (cost=310.15..329.35 rows=1582 width=56) |
Hash Cond: (t.project_id = p_1.id) |
-> HashAggregate (cost=25.64..33.23 rows=607 width=40) |
Group Key: t.project_id, r.user_id |
-> Hash Right Join (cost=1.20..21.09 rows=607 width=40) |
Hash Cond: (r.erp_profit_distribute_id = t.id) |
-> Seq Scan on tbl_erp_profit_distribute_pcts r (cost=0.00..17.80 rows=780 width=40) |
-> Hash (cost=1.11..1.11 rows=7 width=8) |
-> Seq Scan on tbl_erp_profit_distributes t (cost=0.00..1.11 rows=7 width=8) |
Filter: ((project_id IS NOT NULL) AND (status = 2)) |
-> Hash (cost=264.73..264.73 rows=1582 width=20) |
-> Hash Right Join (cost=196.62..264.73 rows=1582 width=20) |
Hash Cond: (sc.from_project = p_1.id) |
-> Seq Scan on tbl_sales_contracts sc (cost=0.00..63.71 rows=1671 width=4) |
-> Hash (cost=176.85..176.85 rows=1582 width=20) |
-> Seq Scan on tbl_projects p_1 (cost=0.00..176.85 rows=1582 width=20) |
Filter: (project_status = 3) |
-> Hash (cost=3.16..3.16 rows=1 width=68) |
-> Subquery Scan on o (cost=3.14..3.16 rows=1 width=68) |
-> HashAggregate (cost=3.14..3.15 rows=1 width=68) |
Group Key: t_1.project_id |
-> Hash Right Join (cost=1.22..3.11 rows=4 width=13) |
Hash Cond: (eipss.erp_sales_outbound_id = t_1.id) |
-> Seq Scan on tbl_erp_inventory_product_spents eipss (cost=0.00..1.68 rows=68 width=13) |
-> Hash (cost=1.21..1.21 rows=1 width=8) |
-> Seq Scan on tbl_erp_sales_outbounds t_1 (cost=0.00..1.21 rows=1 width=8) |
Filter: ((project_id IS NOT NULL) AND (status = 2)) |