Add: create Top_10_Customers.sql for retrieving the top 10 customers based on sales and quantity

This commit is contained in:
OsandaHettiarachchi committed 2025-07-01 14:41:58 +05:30
1 parent 4e5154792b
commit 713cb81bb4
1 file changed
+19
+19
View File
@@ -0,0 +1,19 @@
SELECT CUSTOMER_NO AS Customer,
CUSTOMER_NAME,
ACCT_CURRENCY_CODE AS Currency,
SUM(NET_AMOUNT) AS Sales,
SUM(INVOICED_QTY) AS Quantity
FROM CUST_ORD_INVO_STAT t
Where (TRUNC(INVOICE_DATE) >= TO_DATE('&Valid_From', 'MM/DD/YYYY') AND
TRUNC(INVOICE_DATE) <= TO_DATE('&Valid_To', 'MM/DD/YYYY'))
AND COMPANY LIKE '%&COMPANY%'
AND AUTHORIZE_CODE LIKE '%&AUTHORIZE_CODE%'
AND CUST_GRP LIKE '%&CUST_GRP%'
GROUP BY CUSTOMER_NO, CUSTOMER_NAME, ACCT_CURRENCY_CODE
ORDER BY Sales DESC, Quantity DESC
FETCH NEXT 10 ROWS ONLY
-- Lov reference is removed due to limitations in IFS cloud