Count, inner join

Posted by Urosh on Stack Overflow See other posts from Stack Overflow or by Urosh
Published on 2012-06-01T04:32:43Z Indexed on 2012/06/01 4:40 UTC
Read the original article Hit count: 109

I have two tables:

DRIVER

(Driver_Id,First name,Last name,...)

PARTICIPANT IN CAR ACCIDENT

(Participant_Id,Driver_Id-foreign key,responsibility-yes or no,...)

Now, I need to find out which driver participated in accident where responsibility is 'YES', and how many times. I did this:

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

But, I need to add drivers first and last name from the first table(using inner join, I suppose). I don't know how, because it is not contained in either an aggregate function or the GROUP BY clause. Please help :)

© Stack Overflow or respective owner

Related posts about sql

Related posts about count