In NetSuite, SuiteQL allows you to extract and manipulate data from your NetSuite account. It offers flexibility and efficiency in accessing data, enabling users to write complex queries to retrieve specific information.
Here’s a sample SuiteQL query to calculate total sales per day:
SELECT
TranDate,
COUNT(*) as Count,
SUM(ForeignTotal) as Total
FROM
Transaction
WHERE
( Type = 'SalesOrd' )
AND ( TranDate = TO_DATE('2023-12-22', 'YYYY-MM-DD') )
GROUP BY
TranDate
Explanation of the Query
SELECT Clause:
- TranDate: The date of the transaction.
- COUNT(*) AS Count: Counts the number of sales orders on the specified date.
- SUM(ForeignTotal) AS Total: Calculates the total amount of sales orders for that day.
FROM Clause:
- Specifies the Transaction table from which the data is retrieved.
WHERE Clause:
- Type = ‘SalesOrd’: Filters the records to include only those of type ‘SalesOrd’, which stands for sales orders.
- TranDate = TO_DATE(‘2023-12-22’, ‘YYYY-MM-DD’): Filters the records to include only those with the transaction date of December 22, 2023. Note: You can adjust this date to any day you wish to review sales for.
GROUP BY Clause:
- TranDate: Groups the results by the transaction date, ensuring that the COUNT and SUM functions are applied to each date separately.
This query is useful for businesses to analyze their daily sales performance. By executing this query, users can quickly obtain the number of sales orders and the total amount for a specific day, enabling them to assess daily sales activities and make informed decisions based on the results.