This includes only traffic violation stops for consistency with RIPA 2020 annual report
SELECT IN_TWILIGHT, RACE_ETHNICITY, COUNT(*) as N FROM ( SELECT main.UNIQUE_ID, main.AGENCY_NAME, main.DATE_OF_STOP, main.CLOSEST_CITY, racen_codes.RACE_ETHNICITY, TIME_OF_STOP, twilight.CTWILIGHT_BEGIN as twilight_begin, twilight.CTWILIGHT_END as twilight_end, CASE WHEN TIME_OF_STOP > twilight.CTWILIGHT_BEGIN AND TIME_OF_STOP < twilight.CTWILIGHT_END THEN "Within civil twilight" ELSE "in the dark..." END as IN_TWILIGHT FROM aa_main_table as main INNER JOIN civil_twilight_hours as twilight ON twilight.DATE_OF_STOP = main.DATE_OF_STOP AND twilight.CLOSEST_CITY = main.CLOSEST_CITY INNER JOIN race_ethnicity as racen ON racen.UNIQUE_ID = main.UNIQUE_ID INNER JOIN race_ethnicity_codes as racen_codes ON racen_codes.CODE = racen.RAE_FULL WHERE main.REASON_FOR_STOP = 1 ) WHERE AGENCY_NAME = :agency GROUP BY AGENCY_NAME, RACE_ETHNICITY, IN_TWILIGHT
If you think this query provides useful or interesting information submit it as a suggestion to be included as a canned query! Canned queries are displayed in the main page and come with their own URL. Others might find your query useful in their work!