chekos / RIPA-2018-datasette

Publishing datasette of CA's RIPA 2018 data
http://ripa-2018.datasettes.cimarron.io/
GNU General Public License v3.0
0 stars 0 forks source link

Query suggestion #24

Closed chekos closed 4 years ago

chekos commented 4 years ago

Fixing Reason for stop by race/ethnicity

query

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