SuiteQL: Retrieve Top-Selling Items

SELECT item.itemid, 
       SUM(transactionlines.quantity) AS total_sold 
FROM transaction 
INNER JOIN transactionlines 
ON transaction.id = transactionlines.transaction 
INNER JOIN item 
ON transactionlines.item = item.id 
WHERE transaction.type = 'SalesOrd' 
AND transaction.status = 'SalesOrd:B' 
GROUP BY item.itemid 
ORDER BY total_sold DESC 
LIMIT 10;

Identifies the top 10 best-selling items based on quantities sold (SUM(transactionlines.quantity)).

Filters billed sales orders (status = 'SalesOrd:B').

Uses LIMIT 10 to restrict results to the top 10 items.

Leave a comment

Your email address will not be published. Required fields are marked *