/* Ranked Client Revenue — fact sample / totals (DatawarehouseNCM) Quick check that FactRankedClientRevenue loaded. */ DECLARE @StartDate datetime = '2026-01-01'; DECLARE @EndDate datetime = '2026-01-31'; -- Detail sample SELECT TOP 100 f.CorpCode, c.FormalName, c.ParentCompany, c.MarketingCRD, f.TrxDate, f.Amount, f.ServiceCode, f.ServiceType, f.ServiceGroupCode, f.CodeId, f.IsDirectCost, f.Source FROM dbo.FactRankedClientRevenue f LEFT JOIN dbo.DimCorpClient c ON RTRIM(c.CorpCode) = RTRIM(f.CorpCode) WHERE f.TrxDate BETWEEN @StartDate AND @EndDate ORDER BY f.TrxDate DESC, f.CorpCode; -- Totals by source SELECT f.Source, COUNT(*) AS [RowCount], SUM(f.Amount) AS Amount FROM dbo.FactRankedClientRevenue f WHERE f.TrxDate BETWEEN @StartDate AND @EndDate GROUP BY f.Source ORDER BY f.Source; -- Totals by service group (raw; no ServiceType=2 remap) SELECT f.ServiceGroupCode, SUM(f.Amount) AS Amount FROM dbo.FactRankedClientRevenue f WHERE f.TrxDate BETWEEN @StartDate AND @EndDate AND ISNULL(f.IsDirectCost, 0) = 0 GROUP BY f.ServiceGroupCode ORDER BY f.ServiceGroupCode;