You may need some knowledge of cricket to help with this one. Given the following table, would this query produce this result?
Table: batsmen
batsmanname | runsscored | howout
Colin | 10 | bowled
Colin | 20 | caught
Steve | 10 | bowled
Steve | 20 | not out
SELECT batsmanname, SUM(runsscored) / COUNT(howout) AS battingavg
FROM batsmen
WHERE howout <> 'not out'
GROUP BY batsmananme
Result:
batsmanname | battingavg
Colin | 15
Steve | 30
This should produce the results that you want:
See SQL Fiddle with demo