countDistinct method

MssqlQuery countDistinct(
  1. Iterable<MssqlExpression> expressions
)

The number of distinct values of expressions among the rows this query matches.

One expression compiles to COUNT_BIG(DISTINCT …). Several cannot: SQL Server's COUNT(DISTINCT …) takes exactly one argument, so a composite key is counted through a derived SELECT DISTINCT of its columns. Reducing a composite key to its first column would compile and return a smaller number, which is why the two shapes live behind one method that knows which it is looking at.

Implementation

MssqlQuery countDistinct(Iterable<MssqlExpression> expressions) =>
    _countDistinct(expressions);