Understanding Customer transaction behavior is essential for making informed business decisions. As an Administrator, having quick access to summarized data such as total spend, average transaction value, and transaction frequency can help you identify high-value customers, monitor trends, and support strategic planning.
This article demonstrates how you can use SuiteAnalytics (via SQL queries) to generate a clear, aggregated view of customer transactions by type.
Sample Query
SELECT
c.entityid AS customer_name, -- Customer display name for clear account identification
t.type AS transaction_type, -- Transaction type (e.g., SalesOrd, CustInvc, etc.)
AVG(t.foreigntotal) AS avg_amount, -- Average transaction amount for each unique customer & type (using transaction/foreign currency)
SUM(t.foreigntotal) AS total_amount, -- Total transaction value for each customer/type
COUNT(t.id) AS transaction_count -- Number of transactions for each customer/type
FROM transaction t
JOIN customer c ON t.entity = c.id -- Link each transaction to its customer for accurate grouping
GROUP BY c.entityid, t.type -- Aggregate separately for each customer and transaction type
ORDER BY
total_amount DESC, -- Rank by top transaction amount first
customer_name,
transaction_type
- Customer Name (entityid): Displays the customer’s name for easy identification.
- Transaction Type (type): Groups data by transaction categories such as Sales Orders or Invoices.
- Average Amount (AVG): Shows the typical transaction size per customer and type.
- Total Amount (SUM): Calculates the total value of all transactions per grouping.
- Transaction Count (COUNT): Indicates how frequently each customer transacts.
- JOIN Clause: Links transactions to their respective customers for accurate reporting.
- GROUP BY Clause: Ensures aggregation is done per customer and transaction type.
- ORDER BY Clause: Prioritizes customers with the highest total transaction value.
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.