Description:
#sql #datascience #dataanlysis
In this video we take a messy location column with ZIP codes, cities, and states all jumbled together, extract just the ZIP code using PATINDEX and SUBSTRING, map it to a region using a lookup table, and find out which region is driving the most revenue.
Here is our SQL workflow
PATINDEX — finds the position of the ZIP code in the messy location string
SUBSTRING — extracts exactly 5 characters from that position
LEFT JOIN — matches the clean ZIP code to the lookup table
SUM — totals revenue by region
AVG — calculates average deal size by region
Find the Datasets here:
Main Sales Table
https://github.com/Gaelim/youtube/blob/master/sales_location.csv
Zipcode mapping table
https://github.com/Gaelim/youtube/blob/58941e21855c867f6731625dd8d8b509868aa483/zip_lookup.csv
My Linked Profile
https://www.linkedin.com/gaelimholland
Share this link via
Or copy link
























