Announcements
SELECT
CustTable.MainContactWorker,
hcmWorker.RecId AS MainContactWorkerRecId,
dirPartyTable.Name AS MainContactWorkerName,
COUNT(DISTINCT CustTable.RecId) AS CustomerCount, -- Use DISTINCT to avoid duplicates
SUM(ISNULL(CustTrans.AmountMST, 0)) AS TotalInvoiceAmount
FROM
CustTable
LEFT JOIN
CustTrans ON CustTrans.AccountNum = CustTable.AccountNum
AND CustTrans.TransDate >= '2023-12-01'
AND CustTrans.TransDate <= '2023-12-31' -- Ensure the date range includes transactions
AND (CUSTTRANS.TRANSTYPE=2 OR CUSTTRANS.TRANSTYPE=36)
INNER JOIN
HcmWorker ON HcmWorker.RecId = CustTable.MainContactWorker
INNER JOIN
DirPartyTable ON DirPartyTable.RecId = HcmWorker.Person
WHERE
CustTable.CREATEDDATETIME >= '2023-12-01'
AND CustTable.CREATEDDATETIME <= '2023-12-31'
GROUP BY
CustTable.MainContactWorker,
HcmWorker.RecId,
DirPartyTable.Name;
André Arnaud de Cal... 291,331 Super User 2024 Season 2
Martin Dráb 230,333 Most Valuable Professional
nmaenpaa 101,156