sum<T> method

Future<T?> sum<T>(
  1. MssqlSession session,
  2. String column, {
  3. MssqlDialect dialect = MssqlDialect.sql2012,
})

SUM of column over the rows this query returns, or null for none.

T is unbounded on purpose. T extends num would read as the safe choice and would be the lossy one: MssqlDecimal is not a num, so a bound would force the sum of a decimal or money column through double and drop digits past about the fifteenth — the one thing exact decimal exists to prevent. Ask for sum<MssqlDecimal> on an exact column and sum<int> / sum<double> on the others; a T the value cannot become is a cast error naming the column, not a rounded answer.

Implementation

Future<T?> sum<T>(
  MssqlSession session,
  String column, {
  MssqlDialect dialect = MssqlDialect.sql2012,
}) => _aggregate<T>(session, 'SUM', column, dialect);