inst/QueryLibrary/Aggregate/person/PE08.md

PE08: Number of patients grouped by zip code of residence

Description

Counts the patients' zip of their residence location across all person records. All possible values for zip are summarized. Zip code contains only the first 3 digits in most databases.

Query

SELECT
  state,
  zip,
  COUNT(*)::integer AS num_persons
FROM @cdm.person
  LEFT JOIN @cdm.location ON person.location_id = location.location_id
GROUP BY state, zip
ORDER BY state, zip
;

Input

None

Output

| Field | Description | | --- | --- | | state | State of residence | | zip | 3 digit zip code of residence | | num_persons | Number of patients in the dataset residing in a specific zip code |

Example output record

| Field | Value | | --- | --- | | state | MA | | zip | 019 | | num_persons | 477825 |

Documentation

https://github.com/OHDSI/CommonDataModel/wiki/PERSON

Sensitive fields

num_persons



sib-swiss/dsQueryLibraryServer documentation built on Feb. 13, 2025, 8:07 p.m.