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 #29

Closed chekos closed 4 years ago

chekos commented 4 years ago

Reason for Stop by Race/Ethnicity

Using AGENCY_NAME as a query parameter.

Should include AGENCY_NAMES options in html description.

query


select
  rae_codes.RACE_ETHNICITY,
  rfs_codes.REASON_FOR_STOP,
  COUNT(*) as N
from
  aa_main_table as main
JOIN race_ethnicity as rae
  ON rae.UNIQUE_ID = main.UNIQUE_ID
JOIN race_ethnicity_codes as rae_codes
  ON rae.RAE_FULL = rae_codes.CODE
JOIN rfs_codes
  on main.REASON_FOR_STOP = rfs_codes.CODE
where
  "AGENCY_NAME" = :agency
group by
  main.REASON_FOR_STOP, rae.RAE_FULL
order by
  RACE_ETHNICITY, N DESC