I would like to count rows with the same serv AND spec. The below query counts the rows correctly:
SELECT *, COUNT(*) AS c
FROM table1
GROUP BY serv, spec
But I would like the output displayed as such:
Original:
+-----+------+------+
| id | serv | spec |
| 500 | 1 | 4 |
| 501 | 5 | 1 |
| 502 | 1 | 4 |
| 503 | 1 | 5 |
| 504 | 5 | 6 |
| 505 | 2 | 4 |
| 506 | 5 | 1 |
| 507 | 2 | 4 |
| 508 | 4 | 3 |
| 509 | 2 | 4 |
+-----+------+------+
Desired output:
+-----+------+------+-------+
| id | serv | spec | count |
| 500 | 1 | 4 | 2 |
| 502 | 1 | 4 | 2 |
| 503 | 1 | 5 | 1 |
| 505 | 2 | 4 | 3 |
| 507 | 2 | 4 | 3 |
| 509 | 2 | 4 | 3 |
| 508 | 4 | 3 | 1 |
| 501 | 5 | 1 | 2 |
| 506 | 5 | 1 | 2 |
| 504 | 5 | 6 | 1 |
+-----+------+------+-------+