1. Maths inside SELECT
A column in SELECT can be a calculation: + - * /. Give it a name with AS:
SELECT name, runs / matches AS per_match FROM players;
But wait — 1680 / 42 gives 40 while 1925 / 45 gives 42, not 42.78! When both numbers are whole numbers (integers), SQLite does integer division and throws away the decimal part. The fix: multiply by 1.0 first, so the maths uses decimals:
runs * 1.0 / matches
Then ROUND(value, 1) rounds to 1 decimal place.
SELECT name,
runs / matches AS wrong,
runs * 1.0 / matches AS right
FROM players;
Challenge: Runs per match for batters
For players whose role is Batter, show name and ROUND(runs * 1.0 / matches, 1) named average. Sort by average, highest first.