Understanding how Customers are distributed among Sales Representatives is important for monitoring workload, evaluating performance, and ensuring balanced account management. NetSuite Administrators and analysts often need quick visibility into which Sales Reps manage the largest number of active Customers. Using SuiteQL, you can quickly retrieve a list of sales representatives and the number of active customers assigned to each of them.
Sample Query: Active Customers Per Sales Rep
SELECT
e.entityid AS salesrep_name, -- Sales rep display name
COUNT(DISTINCT c.id) AS customer_count -- Unique count of active customers per rep
FROM customer c
JOIN employee e ON c.salesrep = e.id -- Join customer to their assigned sales rep
WHERE c.isinactive = 'F' -- Only include active customers
GROUP BY e.entityid
ORDER BY customer_count DESC -- Show reps with the largest portfolios first
- JOIN: Links each customer to their assigned sales rep (employee).
- COUNT(DISTINCT c.id): Counts the unique customer IDs for each sales rep—ensuring no duplicates inflate the numbers.
- WHERE: Filters out inactive customers, so only current accounts are counted for each rep.
- GROUP BY: Aggregates the data per rep, so every row is one sales rep and their count of active customers.
- ORDER BY: Prioritizes those reps managing the most customer accounts at the top, making it easy to spot both high performers and those who may need more business.
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.