/* Imprest Account — fact sample / sanity (DatawarehouseNCM) */ SELECT TOP 50 f.FactImprestAccountID, f.CorpCode, f.TEFileNo, f.TrxDate, f.SourceTrxDate, f.InOut, f.Source, f.PhsCtg, f.Amount, f.IsCheck, f.IsFeeOffset, f.DocumentNo, f.CheckLagDays FROM dbo.FactImprestAccount f ORDER BY f.TrxDate DESC, f.FactImprestAccountID DESC; SELECT f.Source, f.InOut, SUM(CASE WHEN f.IsCheck = 1 THEN 1 ELSE 0 END) AS CheckLines, SUM(CASE WHEN f.IsFeeOffset = 1 THEN 1 ELSE 0 END) AS FeeOffsetLines, COUNT(*) AS LineCount, SUM(f.Amount) AS NetAmount FROM dbo.FactImprestAccount f GROUP BY f.Source, f.InOut ORDER BY f.Source, f.InOut; SELECT f.CorpCode, f.FormalName, COUNT(*) AS LineCount, COUNT(DISTINCT f.TEFileNo) AS TECount, SUM(f.Amount) AS NetAmount FROM dbo.FactImprestAccount f GROUP BY f.CorpCode, f.FormalName ORDER BY LineCount DESC; SELECT TOP 50 b.FactImprestAccountBalanceID, b.CorpCode, b.BalanceDate, b.Balance, b.PONumber FROM dbo.FactImprestAccountBalance b ORDER BY b.BalanceDate DESC, b.CorpCode;