Understanding the relationship between Customers and their assigned Sales Representatives is crucial when analyzing unbilled revenue. By accurately linking each Sales Order to the Customer record, you ensure that your reporting reflects true sales ownership and provides meaningful insights for decision-making.
With SuiteQL, you can easily achieve this through proper JOIN logic—allowing you to calculate each Sales Rep’s average unbilled Sales Order amount based on real customer-transaction associations, rather than relying on incomplete or isolated fields.
SuiteQL Sample:
SELECT c.salesrep, AVG(t.amountunbilled) AS avg_order_value
FROM transaction t
JOIN customer c ON t.entity = c.id
WHERE t.type = 'SalesOrd'
GROUP BY c.salesrep
ORDER BY avg_order_value DESC
- JOIN customer c ON t.entity = c.id: Accurately links each Sales Order transaction to the Customer it belongs to, ensuring correct data association.
- c.salesrep: Retrieves the internal ID of the Sales Rep assigned to each Customer.
- AVG(t.amountunbilled): Calculates the average unbilled amount of all Sales Orders associated with each Sales Rep, based on actual customer-transaction relationships.
- GROUP BY c.salesrep: Aggregates the average calculation separately for each Sales Rep.
- ORDER BY avg_order_value DESC: Sorts the results so sales reps with the highest average unbilled order amount appear 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.