My table looks like
person_id | car_id | miles
------------------------------
1 | 1 | 100
1 | 2 | 200
2 | 3 | 1000
2 | 4 | 500
I need to add miles for each person, and then average these amounts.
There are 2 people - person 1 drove 300 miles, person 2 drove 1,500 miles.
(300 + 1500) / 2 = 900 average number of miles per person.
This is the same as the total number of miles and the division by the number of people.
I cannot understand the mySQL statement, which will either give me the average number of people, or give me the total number of miles and the number of people so that I can perform the separation.
source
share