exclude null values in sql

PHOTO EMBED

Tue Apr 05 2022 03:04:51 GMT+0000 (Coordinated Universal Time)

Saved by @Bambibo9799

To exclude entries with “0”, you need to use NULLIF() with function AVG().

SELECT AVG(NULLIF(yourColumnName, 0)) AS anyAliasName FROM yourTableName;
mysql> select AVG(nullif(StudentMarks, 0)) AS Exclude0Avg from AverageDemo;
content_copyCOPY