Example SQL Queries
Here we provide several example SQL queries for commonly requested data. You can use these queries to explore the database directly or as a starting point for your own queries. Copy your desired query and paste it into the SQL editor below to retrieve the data you need.
Retrieving HSA identification data, filtered by desired state:
SELECT
hospital_atlas_data.hsa,
hospital_atlas_data.hsaname,
hospital_atlas_data.shortname,
hospital_atlas_data.year,
hospital_atlas_data.latitude,
hospital_atlas_data.longitude
FROM
hospital_atlas_data
WHERE
hospital_atlas_data.pstate = :state
LIMIT
10000;
Retrieving HSA-level data used for the HSA Dashboard by joining tables: hospital_atlas_data, referral_network_features, and population_census:
SELECT
hospital_atlas_data.hsa,
hospital_atlas_data.year,
hospital_atlas_data.latitude,
hospital_atlas_data.longitude,
referral_network_features.forman_mean,
referral_network_features.forman_median,
referral_network_features.forman_mode,
referral_network_features.forman_stdev,
referral_network_features.average_clustering,
referral_network_features.nnodes,
population_census.median_hh_income,
population_census.employment_pop,
population_census.employment_unemployed_pop,
population_census.education_pop,
population_census.education_nohs_pop
FROM
hospital_atlas_data
JOIN referral_network_features ON hospital_atlas_data.hsa = referral_network_features.hsa
AND hospital_atlas_data.year = referral_network_features.year
JOIN population_census ON hospital_atlas_data.hsa = population_census.hsa
AND hospital_atlas_data.year = population_census.year
WHERE
hospital_atlas_data.year = 2017
LIMIT
10000;