Preview:
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;
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter