countDistinctColumns method
Future<int>
countDistinctColumns(
- MssqlSession session,
- Iterable<
String> columns, { - MssqlDialect dialect = MssqlDialect.sql2012,
- Duration? timeout,
How many distinct values of columns the matched rows hold.
A count of parents rather than of join result rows: a query joined to a
child table returns one row per child, and countDistinct(['Id']) is
what asks the other question.
Implementation
Future<int> countDistinctColumns(
MssqlSession session,
Iterable<String> columns, {
MssqlDialect dialect = MssqlDialect.sql2012,
Duration? timeout,
}) async {
final rows = await countDistinct(
columns.map<MssqlExpression>(Col).toList(growable: false),
).get(session, dialect: dialect, timeout: timeout);
return rows.isEmpty ? 0 : (rows.first.at(0)! as num).toInt();
}