ShopSwift wants to identify which product categories are driving shipping cost increases. Write a SQL query to find the top categories contributing to shipping cost growth from February 2024 to March 2024.
shipments table.category, calculate total shipping cost in February 2024 and March 2024.march_total - february_total).shipments
| Column | Type | Description |
|---|---|---|
| shipment_id | INT | Unique shipment record ID |
| category | VARCHAR(50) | Product category |
| shipped_date | DATE | Shipment date |
| shipping_cost | DECIMAL(10,2) | Cost charged for shipping |
| carrier | VARCHAR(50) | Shipping carrier |
| shipment_id | category | shipped_date | shipping_cost | carrier |
|---|---|---|---|---|
| 1 | Electronics | 2024-03-05 | 120.00 | FedEx |
| 2 | Books | 2024-02-10 | 25.00 | UPS |
| 3 | Electronics | 2024-02-12 | 80.00 | DHL |
| 4 | Home | 2024-03-08 | 60.00 | UPS |
| 5 | Books | 2024-03-14 | 40.00 | FedEx |
| 6 | Toys | 2024-02-20 | 30.00 | USPS |
| 7 | Home | 2024-02-18 | 55.00 | DHL |
| 8 | Electronics | 2024-03-18 | 90.00 | UPS |
| 9 | Toys | 2024-03-21 | 70.00 | FedEx |
| 10 | Beauty | 2024-03-25 | 20.00 | USPS |
| category | february_total | march_total | growth_amount |
|---|---|---|---|
| Electronics | 80.00 | 210.00 | 130.00 |
| Toys | 30.00 | 100.00 | 70.00 |
| Books | 25.00 | 80.00 | 55.00 |
| Column | Type | Description |
|---|---|---|
| shipment_idPK | INT | Unique shipment record ID |
| category | VARCHAR(50) | Product category for the shipped item |
| shipped_date | DATE | Date the shipment was sent |
| shipping_cost | DECIMAL(10,2) | Shipping cost for the shipment |
| carrier | VARCHAR(50) | Carrier used for the shipment |
{"shipments":[["1","Electronics","2024-03-05","120.00","FedEx"],["2","Books","2024-02-10","25.00","UPS"],["3","Electronics","2024-02-12","80.00","DHL"],["4","Home","2024-03-08","60.00","UPS"],["5","Books","2024-03-14","40.00","FedEx"],["6","Toys","2024-02-20","30.00","USPS"],["7","Home","2024-02-18","55.00","DHL"],["8","Electronics","2024-03-18","90.00","UPS"],["9","Toys","2024-03-21","70.00","FedEx"],["10","Beauty","2024-03-25","20.00","USPS"],["11","Books","2024-03-28","40.00",null],["12","ToyOutput[["Appliances","0","222.00","222.00"],["Electronics","80.00","300.00","220.00"],["null","59.00","200.00","141.00"]]