driver_id from the Rides table to get a list of all drivers.LEFT JOIN on the Rides table with itself, joining on driver_id and passenger_id.GROUP BY to group the results by driver_id.COUNT to count the number of times each driver_id appears as a passenger_id in the joined table.IFNULL to replace NULL counts with 0, ensuring that drivers who have never been passengers are included in the results with a count of 0.
erDiagram
Rides {
int ride_id PK
int driver_id
int passenger_id
}