Write SQL and Python, run instantly in your browser, and track your progress.
You are a Data Analyst at Walmart. The operations team is building a new, company-wide dashboard in Tableau to monitor order fulfillment in real-time. To ensure the dashboard's filters and charts work correctly, they need a clean, standardized data source. The raw orders table has several text fields with inconsistent casing.
Your task is to write a SQL query that produces a standardized view of all orders. Specifically, you need to convert the status, payment_status, fulfillment_type, and ship_country columns to all uppercase.
The final output should be sorted by order_number to make it easy to look up specific orders.
You are a Data Analyst at Walmart. The operations team is building a new, company-wide dashboard in Tableau to monitor order fulfillment in real-time. To ensure the dashboard's filters and charts work correctly, they need a clean, standardized data source. The raw orders table has several text fields with inconsistent casing.
Your task is to write a SQL query that produces a standardized view of all orders. Specifically, you need to convert the status, payment_status, fulfillment_type, and ship_country columns to all uppercase.
The final output should be sorted by order_number to make it easy to look up specific orders.
| Column Name | Type |
|---|---|
| order_id | INTEGER |
| order_number | TEXT |
| customer_id | INTEGER |
| order_datetime | TEXT |
| status | TEXT |
| fulfillment_type | TEXT |
| ship_city | TEXT |
| state | TEXT |
| Column Name | Type |
|---|---|
| order_id | INTEGER |
| order_number | TEXT |
| customer_id | INTEGER |
| order_datetime | TEXT |
| status | TEXT |
| fulfillment_type | TEXT |
| ship_city | TEXT |
| state | TEXT |
| order_id | order_number | customer_id | order_datetime | status | fulfillment_type | ship_city | ship_state | ship_country | shipping_service_level | subtotal | shipping_fee | tax | discount | total_amount |
|---|
| order_id | order_number | customer_id | order_datetime | status | fulfillment_type | ship_city | ship_state | ship_country | shipping_service_level | subtotal | shipping_fee | tax | discount | total_amount |
|---|
| order_id | order_number | status_upper | pay_status_up | fulfill_up | ship_country_up |
|---|---|---|---|---|---|
| 1 | ORD-10001 | SHIPPED | CAPTURED | PICKUP | |
| 2 | ORD-10002 | DELIVERED | PARTIAL_REFUND | SHIP | US |
| 3 | ORD-10003 |
| order_id | order_number | status_upper | pay_status_up | fulfill_up | ship_country_up |
|---|---|---|---|---|---|
| 1 | ORD-10001 | SHIPPED | CAPTURED | PICKUP | |
| 2 | ORD-10002 | DELIVERED | PARTIAL_REFUND | SHIP | US |
| 3 | ORD-10003 |
Showing first 5 of 75 rows. Orders with standardized status values in uppercase.
Showing first 5 of 75 rows. Orders with standardized status values in uppercase.
Your final output should be a result set that meets the following requirements:
1. Transformations:
status column must be converted to uppercase and aliased as status_upper.payment_status column must be converted to uppercase and aliased as pay_status_up.fulfillment_type column must be converted to uppercase and aliased as fulfill_up.ship_country column must be converted to uppercase and aliased as .Your final output should be a result set that meets the following requirements:
1. Transformations:
status column must be converted to uppercase and aliased as status_upper.payment_status column must be converted to uppercase and aliased as pay_status_up.fulfillment_type column must be converted to uppercase and aliased as fulfill_up.ship_country column must be converted to uppercase and aliased as .| ship_country | TEXT |
| ship_country | TEXT |
| shipping_service_level | TEXT |
| shipping_service_level | TEXT |
| subtotal | REAL |
| subtotal | REAL |
| shipping_fee | REAL |
| shipping_fee | REAL |
| tax | REAL |
| tax | REAL |
| discount | REAL |
| discount | REAL |
| total_amount | REAL |
| total_amount | REAL |
| payment_status | TEXT |
| payment_status | TEXT |
| created_at | TEXT |
| created_at | TEXT |
| payment_status |
|---|
| payment_status |
|---|
| created_at |
|---|
| created_at |
|---|
| 1 | ORD-10001 | 46 | 2025-08-20 07:01:34 | shipped | pickup | pickup | 50.96 | 0.0 | 4.36 | 0.0 | 55.32 | captured | 2025-08-20 07:01:34 | |||
| 2 | ORD-10002 | 19 | 2025-02-24 04:56:03 | delivered | ship |
| 1 | ORD-10001 | 46 | 2025-08-20 07:01:34 | shipped | pickup | pickup | 50.96 | 0.0 | 4.36 | 0.0 | 55.32 | captured | 2025-08-20 07:01:34 | |||
| 2 | ORD-10002 | 19 | 2025-02-24 04:56:03 | delivered | ship |
| SHIPPED |
| SHIPPED |
| CAPTURED |
| CAPTURED |
| SHIP |
| SHIP |
| UK |
| UK |
| 4 | ORD-10004 | SHIPPED | CAPTURED | SHIP | CA |
| 4 | ORD-10004 | SHIPPED | CAPTURED | SHIP | CA |
| 5 | ORD-10005 | PACKED | CAPTURED | SHIP | CA |
| 5 | ORD-10005 | PACKED | CAPTURED | SHIP | CA |
ship_country_upship_country_upship_country is NULL, it should be converted to an empty string (''), not NULL.ship_country is NULL, it should be converted to an empty string (''), not NULL.2. Columns:
2. Columns:
order_idorder_numberstatus_upperpay_status_upfulfill_upship_country_uporder_idorder_numberstatus_upperpay_status_upfulfill_upship_country_up3. Ordering:
3. Ordering:
order_number in ascending alphabetical order.order_id in ascending order.order_number in ascending alphabetical order.order_id in ascending order.| Austin |
| Austin |
| TX |
| TX |
| US |
| US |
| economy |
| economy |
| 601.53 |
| 601.53 |
| 5.99 |
| 5.99 |
| 54.96 |
| 54.96 |
| 0.0 |
| 0.0 |
| 662.48 |
| 662.48 |
| partial_refund |
| partial_refund |
| 2025-02-24 04:56:03 |
| 2025-02-24 04:56:03 |
| 3 | ORD-10003 | 21 | 2025-02-13 17:43:43 | shipped | ship | London | ENG | UK | expedited | 68.26 | 14.99 | 5.41 | 0.0 | 88.66 | captured | 2025-02-13 17:43:43 |
| 3 | ORD-10003 | 21 | 2025-02-13 17:43:43 | shipped | ship | London | ENG | UK | expedited | 68.26 | 14.99 | 5.41 | 0.0 | 88.66 | captured | 2025-02-13 17:43:43 |
| 4 | ORD-10004 | 8 | 2025-02-07 13:00:50 | shipped | ship | Calgary | AB | CA | standard | 290.99 | 5.0 | 26.88 | 0.0 | 322.87 | captured | 2025-02-07 13:00:50 |
| 4 | ORD-10004 | 8 | 2025-02-07 13:00:50 | shipped | ship | Calgary | AB | CA | standard | 290.99 | 5.0 | 26.88 | 0.0 | 322.87 | captured | 2025-02-07 13:00:50 |
| 5 | ORD-10005 | 8 | 2025-06-24 03:59:58 | packed | ship | Edmonton | AB | CA | standard | 569.61 | 5.0 | 54.73 | 0.0 | 629.34 | captured | 2025-06-24 03:59:58 |
| 5 | ORD-10005 | 8 | 2025-06-24 03:59:58 | packed | ship | Edmonton | AB | CA | standard | 569.61 | 5.0 | 54.73 | 0.0 | 629.34 | captured | 2025-06-24 03:59:58 |