Using the same tables as the prior question, for each username, retrieve the % of their total spend on the Electronics category. If a user has not made any purchases in the Electronics category, their percentage should be displayed as 0.
customers: This table contains information about each customer.
| Column Name | Description |
|---|---|
| customer_id | Unique identifier for a customer |
| name | The customer's full name |
| The customer's email address |
orders: This table tracks each order placed by customers.
| Column Name |
|---|
| Description |
|---|
| order_id | Unique identifier for an order |
| customer_id | ID of the customer who placed the order |
| product_id | ID of the product ordered |
| order_date | Date when the order was placed |
products: This table lists details of products available for purchase.
| Column Name | Description |
|---|---|
| product_id | Unique identifier for a product |
| product_name | Name of the product |
| category | Category of the product |
| price | Price of the product |
| customer_name | percentage_spent |
|---|---|
| Carol Martinez | 100 |
| Kathy Green | 100 |
| Henry Davis | 97.64395555 |
| Frank Murphy | 100 |
| Emma Watson | 62.83617591 |
| Irene Taylor | 94.97870947 |
Using the same tables as the prior question, for each username, retrieve the % of their total spend on the Electronics category. If a user has not made any purchases in the Electronics category, their percentage should be displayed as 0.
customers: This table contains information about each customer.
| Column Name | Description |
|---|---|
| customer_id | Unique identifier for a customer |
| name | The customer's full name |
| The customer's email address |
orders: This table tracks each order placed by customers.
| Column Name | Description |
|---|---|
| order_id | Unique identifier for an order |
| customer_id | ID of the customer who placed the order |
| product_id | ID of the product ordered |
| order_date | Date when the order was placed |
products: This table lists details of products available for purchase.
| Column Name | Description |
|---|---|
| product_id | Unique identifier for a product |
| product_name | Name of the product |
| category | Category of the product |
| price | Price of the product |
| customer_name | percentage_spent |
|---|---|
| Carol Martinez | 100 |
| Kathy Green | 100 |
| Henry Davis | 97.64395555 |
| Frank Murphy | 100 |
| Emma Watson | 62.83617591 |
| Irene Taylor | 94.97870947 |