MssqlWindowExpression.lag constructor

MssqlWindowExpression.lag(
  1. MssqlExpression operand,
  2. MssqlWindow over, {
  3. int offset = 1,
  4. MssqlExpression? ifMissing,
})

LAG(x, offset, ifMissing) OVER (…): operand as of offset rows earlier in the partition.

Without ifMissing the first row of each partition is null: there is no earlier row, and substituting zero would misstate the first change.

Implementation

factory MssqlWindowExpression.lag(
  MssqlExpression operand,
  MssqlWindow over, {
  int offset = 1,
  MssqlExpression? ifMissing,
}) => MssqlWindowExpression._(
  function: MssqlWindowFunction.lag,
  arguments: <MssqlExpression>[operand, ?ifMissing],
  window: over,
  resultType: _offsetResult(operand),
  literalSuffix: _offsetSuffix(offset, ifMissing != null),
);