Understanding who your top Customers are is essential for strategic planning, sales prioritization, and financial analysis. With SuiteQL, NetSuite Administrators can quickly identify Customers generating the highest Invoice totals and gain deeper insight into billing trends.
This article demonstrates how to retrieve the Top 10 Customers with the highest total Invoice amounts, including Invoice count and average Invoice value.
Sample SuiteQL Query
SELECT TOP 10
c.entityid AS customer_name, -- Customer display name
COUNT(t.id) AS invoice_count, -- Number of invoices per customer
SUM(t.foreigntotal) AS total, -- Total invoiced amount (in transaction/foreign currency)
AVG(t.foreigntotal) AS avg_total -- Average total amount per invoice
FROM transaction t
JOIN customer c ON t.entity = c.id -- Link each invoice to its customer
WHERE t.type = 'CustInvc' -- Only consider Invoices
GROUP BY c.entityid
ORDER BY total DESC -- Show top customers by total invoice value
- TOP 10: Returns only the 10 customers with the largest invoiced totals.
- SUM(t.foreigntotal): Adds up the total amount (in the invoice’s own/foreign currency) billed to each customer.
- COUNT, AVG: Tracks invoice volume and average size per customer.
- GROUP BY: Performs all aggregations per customer.
- ORDER BY: Sorts by highest total invoiced first.
To easily execute a SuiteQL query, see NetSuite Admin Tip | Running SUITEQL Using a Suitelet
The sample code described herein is provided on an "as is" basis, without warranty of any kind, to the fullest extent permitted by law. Oracle + NetSuite Inc. does not warrant or guarantee the individual success developers may have in implementing the sample code on their development platforms or in using their own Web server configurations.
Oracle + NetSuite Inc. does not warrant, guarantee or make any representations regarding the use, results of use, accuracy, timeliness or completeness of any data or information relating to the sample code. Oracle + NetSuite Inc. disclaims all warranties, express or implied, and in particular, disclaims all warranties of merchantability, fitness for a particular purpose, and warranties related to the code, or any service or software related thereto.
Oracle + NetSuite Inc. shall not be liable for any direct, indirect or consequential damages or costs of any type arising out of any action taken by you or others related to the sample code.
We’d love to hear how you integrate SuiteQL into your NetSuite processes! Share your insights and experiences in the NetSuite Admin Corner.