我有两张桌子:
DRIVER(Driver_Id,First name,Last name,...);
PARTICIPANT IN CAR ACCIDENT(Participant_Id,Driver_Id-foreign key,responsibility-yes or no,...).
现在,我需要找出责任是“是”的事故是由哪个司机参与的,以及发生了多少次。我这样做了:
Select Driver_ID, COUNT (Participant.Driver_ID)as 'Number of accidents'
from Participant in car accident
where responsibility='YES'
group by Driver_ID
order by COUNT (Participant.Driver_ID) desc
但是,我需要从第一个表中添加驱动程序的名字和姓氏(我想使用内部连接)。我不知道怎么做,因为它既不包含在聚合函数也不包含在 GROUP BY 子句中。请帮忙 :)