Results for “average”
Small, practical examples. Search by task or narrow things down below.
Average a fixed set of readings
Accumulate sample values without overflowing a 16-bit total.
array✓ Tested
Calculate a fixed-window moving average
C: For this small window, sum each complete group and skip incomplete prefixes.
C✓ Tested
Calculate an average without integer division truncation
C: Accumulate into double and divide by the nonzero number of readings.
C✓ Tested
Compare a row with its own group average
SQL: A correlated aggregate computes a different comparison value for each group.
SQL✓ Tested
Compare a row with its own group average
SQL Server: A correlated aggregate computes a different comparison value for each group.
SQL Server✓ Tested
Compare a row with its own group average
Postgres: A correlated aggregate computes a different comparison value for each group.
Postgres✓ Tested
Compare a row with its own group average
SQLite: A correlated aggregate computes a different comparison value for each group.
SQLite✓ Tested
Compute an integer weighted average
SQL: Multiply before summing and guard a zero total weight with NULLIF.
SQL✓ Tested
Compute an integer weighted average
SQL Server: Multiply before summing and guard a zero total weight with NULLIF.
SQL Server✓ Tested
Compute an integer weighted average
Postgres: Multiply before summing and guard a zero total weight with NULLIF.
Postgres✓ Tested
Compute an integer weighted average
SQLite: Multiply before summing and guard a zero total weight with NULLIF.
SQLite✓ Tested
Maintain a rolling sum in a circular window
Arduino / C: Subtract the overwritten sample before adding the next one.
Arduino / C✓ Tested