/* Monthly Auth / Service Count — fact sample (DatawarehouseNCM) FactMonthlyAuthorization sanity checks after populate. */ SELECT COUNT(*) AS FactRows, COUNT(DISTINCT DimMainID) AS DistinctTEs, COUNT(DISTINCT ServiceCode) AS DistinctServices, MIN(AuthorizationDate) AS MinAuthDate, MAX(AuthorizationDate) AS MaxAuthDate, SUM(CASE WHEN SrvcProvider IS NULL THEN 1 ELSE 0 END) AS NullSrvcProvider, SUM(CASE WHEN CAC IS NULL THEN 1 ELSE 0 END) AS NullCAC, SUM(CASE WHEN IncludeInRevenueShare IS NULL THEN 1 ELSE 0 END) AS NullRevenueShare, SUM(CASE WHEN DomesticIntl = 1 THEN 1 ELSE 0 END) AS DomesticRows, SUM(CASE WHEN DomesticIntl = 2 THEN 1 ELSE 0 END) AS InternationalRows FROM dbo.FactMonthlyAuthorization; SELECT TOP 50 m.CorpCode, m.TEFileNo, m.TEName, f.ServiceCode, f.AuthorizationDate, f.CancelDate, f.DepartureOwnRent, f.DomesticIntl, f.UserType, f.ProfitCenter, f.CAC, f.SrvcProvider, f.IncludeInRevenueShare FROM dbo.FactMonthlyAuthorization f INNER JOIN dbo.DimMain m ON f.DimMainID = m.DimMainID ORDER BY f.AuthorizationDate DESC, m.TEFileNo;