text: -- NIBRS Offense Counts
  select EXTRACT(YEAR FROM NI.INCIDENT_DATE) "DATA_YEAR", RS.STATE_ID, RS.STATE_ABBR, ra.agency_id, ra.ORI, NOFT.OFFENSE_NAME, COUNT(DISTINCT NI.INCIDENT_ID) "INCIDENT_COUNT", COUNT(DISTINCT NOFF.OFFENSE_ID) "OFFENSE_COUNT" from
  NIBRS_INCIDENT NI
  JOIN NIBRS_OFFENSE NOFF ON NOFF.INCIDENT_ID = NI.INCIDENT_ID
  JOIN NIBRS_OFFENSE_TYPE NOFT ON NOFT.OFFENSE_TYPE_ID = NOFF.OFFENSE_TYPE_ID
  JOIN REF_AGENCY RA ON RA.AGENCY_ID = NI.AGENCY_ID
  JOIN REF_STATE RS ON RS.STATE_ID = RA.STATE_ID
  where
  EXTRACT(YEAR FROM NI.INCIDENT_DATE) = 2016
  GROUP BY EXTRACT(YEAR FROM NI.INCIDENT_DATE), RS.STATE_ID, RS.STATE_ABBR, ra.agency_id, ra.ORI, NOFT.OFFENSE_NAME
  ORDER BY EXTRACT(YEAR FROM NI.INCIDENT_DATE), RS.STATE_ID, RS.STATE_ABBR, ra.agency_id, ra.ORI, NOFT.OFFENSE_NAME
  