/* Expense Processing Audit — fact sample / sanity (DatawarehouseNCM) Fact: dbo.FactExpenseProcessingAudit */ SELECT TOP 50 f.FactExpenseProcessingAuditID, f.CorpCode, f.TEFileNo, f.TELastName, f.PrimaryContact, f.DomesticIntl, f.AuthDate, f.TransactionDate, f.Category, f.Item, f.Amount, f.Descriptor1, f.Descriptor2, f.DeniedExpense, f.TrackOnly, f.ExceptionLine FROM dbo.FactExpenseProcessingAudit f ORDER BY f.TransactionDate DESC, f.FactExpenseProcessingAuditID DESC; SELECT CONVERT(char(7), f.TransactionDate, 120) AS TrxMonth, COUNT(*) AS LineCount, COUNT(DISTINCT f.TEFileNo) AS TECount, SUM(f.Amount) AS TotalAmount FROM dbo.FactExpenseProcessingAudit f WHERE f.TransactionDate IS NOT NULL GROUP BY CONVERT(char(7), f.TransactionDate, 120) ORDER BY TrxMonth DESC; SELECT f.CorpCode, f.FormalName, COUNT(*) AS LineCount, COUNT(DISTINCT f.TEFileNo) AS TECount, SUM(f.Amount) AS TotalAmount FROM dbo.FactExpenseProcessingAudit f GROUP BY f.CorpCode, f.FormalName ORDER BY LineCount DESC;