Top customers by invoiced amount¶
The 25 customers that have been invoiced the most.
Run it with the run_report tool, passing the report id top-customers. If the workspace has more than one connected entity, also pass the connection_id of the one you want, from list_entities.
Output columns¶
company_nameinvoice_counttotal_invoiced
SQL¶
This is the exact query Kipper runs, against your own data and under your own permissions.
SELECT
c.company_name,
count(t.id) AS invoice_count,
sum(t.total) AS total_invoiced
FROM v_ai_companies c
JOIN v_ai_transactions t ON t.company_external_id = c.source_id
AND t.data_source_id = c.data_source_id
WHERE c.type = 'customer'
AND t.type = 'invoice'
GROUP BY c.company_name
ORDER BY total_invoiced DESC NULLS LAST
LIMIT 25
Limits¶
- Capped at 100 rows.
- Covers one connected entity. To span every entity, use the
run_sqltool withall_entities=truerather than running the report once per entity. - Takes no parameters besides
connection_id, which picks the entity and is required when the workspace has more than one. Any date window a report uses is already part of the SQL above.