Husband, Father, Podcaster, Learning Data Analysis
I created this humble site to provide a place to store different projects. I started to learn SQL and Python in 2021. Since that time, My SQL knowledge has grown to meet the needs for developing reports and dashboards. Each section reflects the work I created either for work or personal learning.
View My LinkedIn Profile
The purpose of the Order Location SQL query is to find where packages are being shipped.
This query first cleans the data through a temporary table. It takes the shipping address from BigCommerce’s bc_order_shipping_addresses
table and joins it to a table containing state and state postcodes. This table was uploaded to BigQuery from a CSV file. This join uses a case
function to check the length of the state code and determines if the ID is on the state postcode or the name. The result returns the state name so everything is uniform. We needed this because some of our API checkouts used state postcode instead of the name. I also used a left to only pull the 5-digit zipcode.
The main query takes the temporary table and joins it with the bc_order
table. This query adds order_created_date_time. It also is needed for the WHERE
statement which reduces the record to only orders with an exchange of money. This means orders which were fully refunded/returned were removed from the query.
I designed this query to be a simple copy-and-paste to add your account information.
project_name.store_name.bc_order_shipping_addresses
and kept the original table names that BigCommerce sends over. You can find the table ids in the table details.