Ever wondered which customers in your NetSuite account have the most Invoices? With SuiteQL, you can easily find out by running a simple SQL query that counts all Invoices per Customer and ranks them from highest to lowest.
This quick tip helps administrators and finance teams identify top invoiced customers, monitor billing activity, and gain valuable insights into customer engagement trends.
SQL Query:
SELECT
c.entityid,
COUNT(t.id) AS number_of_invoices
FROM
customer c
JOIN
transaction t ON t.entity = c.id
WHERE
t.type = 'CustInvc'
GROUP BY
c.entityid
ORDER BY
number_of_invoices DESC
- customer c – Refers to the Customer record table.
- transaction t – Refers to the Transaction record table.
- JOIN t.entity = c.id – Links transactions to the customer that created them.
- WHERE t.type = 'CustInvc' – Filters transactions to include only Customer Invoices.
- COUNT(t.id) – Counts the number of invoices for each customer.
- ORDER BY number_of_invoices DESC – Displays the customers with the highest number of invoices 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.