MssqlWindowExpression.ntile constructor

MssqlWindowExpression.ntile(
  1. int buckets,
  2. MssqlWindow over
)

NTILE(n) OVER (…): which of buckets groups the row falls in.

Implementation

factory MssqlWindowExpression.ntile(int buckets, MssqlWindow over) {
  if (buckets < 1) {
    throw ArgumentError.value(
      buckets,
      'buckets',
      'NTILE splits a partition into at least one group.',
    );
  }
  return MssqlWindowExpression._(
    function: MssqlWindowFunction.ntile,
    arguments: const <MssqlExpression>[],
    window: over,
    resultType: const MssqlColumnType(type: MssqlType.int32, nullable: false),
    // A validated int, and part of the function's shape rather than data.
    literalSuffix: '$buckets',
  );
}