Question
Query
Hello. How do I write the query for:
SELECT * FROM shirt;
+----+---------+--------+-------+
| id | name | num1| num2 |
+----+---------+--------+-------+
| 1 | nancy | 2 | 2 |
| 1 | bill | 1 | 4 |
| 2 | nancy | 3 | 16 |
| 2| bill | 7 | 2 |
| 2| steve | 7 | 6 |
| 3 | pam |8 | 7 |
| 3 | nancy | 1 | 8 |
| 3 | bill | 2 | 7 |
+----+---------+--------+-------+
Which will return this:
+----+---------+--------+-------+
| count | name | num1| num2 |
+----+---------+--------+-------+
| 3 | nancy | 6 | 26 |
| 3 | bill | 10 | 13 |
| 1 | steve | 7 | 6 |
| 1| pam | 8 | 7 |
+----+---------+--------+-------+
Primary Key (ID, unique)
I don't know if I've written everything correctly. I need to count the occurrance of ID for each Name and then show the sum of the values in Num1 and Num2 for each name.
Can anyone help me?
Thank you so much.
SELECT * FROM shirt;
+----+---------+--------+-------+
| id | name | num1| num2 |
+----+---------+--------+-------+
| 1 | nancy | 2 | 2 |
| 1 | bill | 1 | 4 |
| 2 | nancy | 3 | 16 |
| 2| bill | 7 | 2 |
| 2| steve | 7 | 6 |
| 3 | pam |8 | 7 |
| 3 | nancy | 1 | 8 |
| 3 | bill | 2 | 7 |
+----+---------+--------+-------+
Which will return this:
+----+---------+--------+-------+
| count | name | num1| num2 |
+----+---------+--------+-------+
| 3 | nancy | 6 | 26 |
| 3 | bill | 10 | 13 |
| 1 | steve | 7 | 6 |
| 1| pam | 8 | 7 |
+----+---------+--------+-------+
Primary Key (ID, unique)
I don't know if I've written everything correctly. I need to count the occurrance of ID for each Name and then show the sum of the values in Num1 and Num2 for each name.
Can anyone help me?
Thank you so much.
