Datapolitan-Training / parks-advanced-analysis-sql

A one-day class reinforcing the skills necessary to leverage a relational database to clean, process, and visualize NYC Parks data
http://training.datapolitan.com/parks-advanced-analysis-sql
Creative Commons Attribution Share Alike 4.0 International
0 stars 0 forks source link

Add CASE Statement for Boro #61

Closed datapolitan closed 5 years ago

datapolitan commented 5 years ago

matches Excel II learning

SELECT 
CASE 
     WHEN LEFT(omppropid,1) = 'B' THEN 'Brooklyn'
     WHEN LEFT(omppropid,1) = 'M' THEN 'Manhattan'
     WHEN LEFT(omppropid,1) = 'X' THEN 'Bronx'
     WHEN LEFT(omppropid,1) = 'R' THEN 'Staten Island'
     WHEN LEFT(omppropid,1) = 'Q' THEN 'Queens'   
--have a null and a weird blank instance
END AS boro,
 COUNT(*) AS dt_count
FROM tbl_dailytasks
WHERE LEFT(omppropid,1) IS NOT NULL
GROUP BY LEFT(omppropid,1)
ORDER BY LEFT(omppropid,1)