我想选择事故最多的车型。 我正在使用以下查询,但出现语法错误。 请有人告诉我出了什么问题..
select car.Model
from car
join car_accident_involved
on car.Car_Registration_ID = car_accident_involved.Car_Registration_ID
group by car.Model
having MAX(
select COUNT(Car_Registration_ID)
from car_accident_involved
);
最佳答案
您可以在此处使用简单的子查询,例如:
select model from car
where car_registration_id =
(select car_registration_id
from car_accident_involved
group by model
order by count(car_registration_id) desc
limit 1);
关于mysql - 带有子查询MySql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36241848/