| Aggregate (cost=287.05..287.06 rows=1 width=32) |
| -> Limit (cost=286.90..286.92 rows=10 width=32) |
| -> Sort (cost=286.90..291.93 rows=2013 width=32) |
| Sort Key: inner_sub.erp_revenue DESC |
| -> Subquery Scan on inner_sub (cost=177.97..243.40 rows=2013 width=32) |
| -> HashAggregate (cost=177.97..223.27 rows=2013 width=68) |
| Group Key: c.id |
| Filter: ((COALESCE(sum(o.outbound_amount), '0'::numeric) + COALESCE(sum(eoi.amount), '0'::numeric)) > '0'::numeric) |
| -> Hash Left Join (cost=32.09..152.81 rows=2013 width=68) |
| Hash Cond: (c.id = eoi.client_id) |
| -> Hash Left Join (cost=29.33..144.76 rows=2013 width=36) |
| Hash Cond: (c.id = o.client_id) |
| -> Seq Scan on tbl_clients c (cost=0.00..110.13 rows=2013 width=4) |
| Filter: (NOT deleted) |
| -> Hash (cost=28.47..28.47 rows=69 width=36) |
| -> Subquery Scan on o (cost=26.92..28.47 rows=69 width=36) |
| -> HashAggregate (cost=26.92..27.78 rows=69 width=68) |
| Group Key: t.client_id |
| -> Hash Right Join (cost=11.00..24.98 rows=388 width=8) |
| Hash Cond: (eipss.erp_sales_outbound_id = t.id) |
| -> Seq Scan on tbl_erp_inventory_product_spents eipss (cost=0.00..12.51 rows=551 width=8) |
| -> Hash (cost=9.66..9.66 rows=107 width=8) |
| -> Seq Scan on tbl_erp_sales_outbounds t (cost=0.00..9.66 rows=107 width=8) |
| Filter: ((client_id IS NOT NULL) AND (created_at >= '2025-01-01 00:00:00+08'::timestamp with time zone) AND (created_at <= '2025-12-31 23:59:59+08'::timestamp with time zone) AND (status = 2)) |
| -> Hash (cost=2.75..2.75 rows=1 width=36) |
| -> Subquery Scan on eoi (cost=2.71..2.75 rows=1 width=36) |
| -> GroupAggregate (cost=2.71..2.74 rows=1 width=36) |
| Group Key: t_1.client_id |
| -> Sort (cost=2.71..2.71 rows=2 width=10) |
| Sort Key: t_1.client_id |
| -> Seq Scan on tbl_erp_other_income_tickets t_1 (cost=0.00..2.70 rows=2 width=10) |
| Filter: ((client_id IS NOT NULL) AND (created_at >= '2025-01-01 00:00:00+08'::timestamp with time zone) AND (created_at <= '2025-12-31 23:59:59+08'::timestamp with time zone) AND (status = 2)) |