SELECT
rae_codes.RACE_ETHNICITY as race_ethnicity,
rfs_codes.REASON_FOR_STOP as reason_for_stop,
COUNT(main.REASON_FOR_STOP) as total_stops
FROM
aa_main_table as main
INNER JOIN race_ethnicity as rae ON rae.UNIQUE_ID = main.UNIQUE_ID
INNER JOIN race_ethnicity_codes as rae_codes ON rae.RAE_FULL = rae_codes.CODE
INNER JOIN reason_for_stop_codes as rfs_codes ON main.REASON_FOR_STOP = rfs_codes.CODE
GROUP BY
main.REASON_FOR_STOP,
rae.RAE_FULL
ORDER BY
rae_codes.RACE_ETHNICITY
Fixing Reason for stop by race/ethnicity
query