Excel → T-SQL › AVERAGEIF

AVERAGEIF to SQL AVG

AVG ignores NULL. A CASE that returns NULL on the miss is the same as a filter.

SELECT AVG(total_amount) FROM Orders WHERE status = 'Shipped';

SQL will not shout #DIV/0!. NULL means “no rows”. Wrap with ISNULL if the sheet must show 0.

Canonical translation

SELECT AVG(total_amount) FROM Orders WHERE status = 'Shipped';

Then write it on a ticket

Monday is free. A colleague asks, you type, we mark it.

Clock in free