Question: 1.Use COUNT and GROUP BY to write SQL to count the number of products per category in the DEMO_PRODUCT_INFO table. So, when you run it,
1.Use COUNT and GROUP BY to write SQL to count the number of products per category in the DEMO_PRODUCT_INFO table.
So, when you run it, you'll see these results:
| CATEGORY | COUNT(*) |
| Mens | 4 |
| Womens | 3 |
| Accessories | 3 |
2.
Use SUM and GROUP BY to write SQL to write the sum of the quantities of products ordered. Name that column TotalQuantity
Make the results be in the order of PRODUCT_ID.
This will involve the DEMO_ORDER_ITEMS table.
So, when you run it, you'll see these results:
| PRODUCT_ID | TotalQuantity |
| 1 | 23 |
| 2 | 21 |
| 3 | 18 |
| 4 | 16 |
| 5 | 14 |
| 6 | 12 |
| 7 | 11 |
| 8 | 16 |
| 9 | 10 |
| 10 | 11 |
3.
Use AVG and GROUP BY to write SQL to determine the average LIST_PRICE for products that are in the 'Mens' category. HINT - You can use HAVING or WHERE for this question
For the column containing the average value, name it Average
Make the results be in the order of PRODUCT_ID.
This will involve the DEMO_PRODUCT_INFO table.
So, when you run your SQL, you'll see these results:
| PRODUCT_ID | Average |
| 1 | 50 |
| 2 | 80 |
| 3 | 150 |
| 9 | 110 |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
