I have the following table in MySQL
create table alquilan (
matricula varchar(20) not null,
id_usuario numeric not null,
n_tarjeta varchar(50) not null,
codigo_seguridad varchar(10) not null,
precio numeric not null,
check_in date not null,
check_out date not null,
comentario varchar(200) not null,
puntaje numeric not null,
foreign key (id_usuario) references usuarios(id_usuario),
foreign key (matricula) references vehiculos(matricula)
);
Then, every time a car is rented, a new cell will be created with the data of this one, now, having this, how can I calculate the average of the EACH car's score?
I can get the average TOTAL score with select avg(puntaje) from alquilan
, but this would be for all cars.
I would need each of them, for example, if the car with% registration% was rented 3 times, and obtained in those 3 rents AAA-111
, 3
and 4
of score would need to obtain: 7