I have two tables CHICAGO_CRIME_DATA and CENSUS_DATA.
I am running the following query:
select count(id) as NUM_OF_CRIMES, COMMUNITY_AREA_NUMBER
from CHICAGO_CRIME_DATA
group by COMMUNITY_AREA_NUMBER
order by NUM_OF_CRIMES desc
limit 1;
to return a result with two columns:
- NUM_OF_CRIMES
- COMMUNITY_AREA_NUMBER
with the respective values:
- 43
- 25
I now want to add a column to that result called COMMUNITY_AREA_NAME from CENSUS_DATA where the COMMUNITY_AREA_NUMBER = 25.
The column COMMUNITY_AREA_NUMBER is in both of the tables.
I am very new to sql and have tried various implementations with sub-queries and implicit joins using aliases but cannot figure out how to do this, any help would be greatly appreciated!
Thanks