Run sql statement query in D365fo x++
Run sql statement query in D365fo x++ private int getMTDUniqueSKUsSold(TransDate _fromDate, TransDate _toDate, str _empId, InventSiteId _inventSite, str _division) { int uniqueCount; str fromDateStr = date2Str(_fromDate, 321, DateDay::Digits2, DateSeparator::Hyphen, DateMonth::Digits2, DateSeparator::Hyphen, DateYear::Digits4); str toDateStr = date2Str(_toDate, 321, DateDay::Digits2, DateSeparator::Hyphen, DateMonth::Digits2, DateSeparator::Hyphen, DateYear::Digits4); str sql = strFmt(@" SELECT COUNT(DISTINCT CIT.ItemId) FROM CustInvoiceTrans CIT JOIN CustInvoiceJour CIJ ON CIT.InvoiceId = CIJ.InvoiceId JOIN SalesTable ST ON ST.SalesId = CIJ.SalesId JOIN DefaultDimensionView DDV ON DDV.DefaultDimension = ST.DefaultDimension JOIN HcmWorker HW ON HW.RecId = ST.WorkerSalesResponsible WHERE CIJ.InvoiceDate >= '%1' AND CIJ.InvoiceDate <= '%2' AND ST.InventSiteId = '%3' AND DDV.Name = '...