private void AddDistributionColumns(QueryBuilder qb) { var repo = new MemoryRepository(); qb.AddColumn(new SpontaneouslyInventedColumn(repo, "CountTotal", "count(1)")); qb.AddColumn(new SpontaneouslyInventedColumn(repo, "CountNull", "SUM(CASE WHEN " + ColumnInfo.GetFullyQualifiedName() + " IS NULL THEN 1 ELSE 0 END)")); qb.AddColumn(new SpontaneouslyInventedColumn(repo, "CountZero", "SUM(CASE WHEN " + ColumnInfo.GetFullyQualifiedName() + " = 0 THEN 1 ELSE 0 END)")); qb.AddColumn(new SpontaneouslyInventedColumn(repo, "Max", "max(" + ColumnInfo.GetFullyQualifiedName() + ")")); qb.AddColumn(new SpontaneouslyInventedColumn(repo, "Min", "min(" + ColumnInfo.GetFullyQualifiedName() + ")")); switch (ColumnInfo.GetQuerySyntaxHelper().DatabaseType) { case DatabaseType.MicrosoftSQLServer: qb.AddColumn(new SpontaneouslyInventedColumn(repo, "stdev ", "stdev(" + ColumnInfo.GetFullyQualifiedName() + ")")); break; case DatabaseType.MySql: case DatabaseType.Oracle: qb.AddColumn(new SpontaneouslyInventedColumn(repo, "stddev ", "stddev(" + ColumnInfo.GetFullyQualifiedName() + ")")); break; default: throw new ArgumentOutOfRangeException(); } qb.AddColumn(new SpontaneouslyInventedColumn(repo, "avg", "avg(" + ColumnInfo.GetFullyQualifiedName() + ")")); }