I need to create a query which will show the amount of query's inserted each day sorted by a type. This sounds pretty vague so I will demonstrate it below:
+----+------+----------+
| id | type | inserted |
+----+------+----------+
| 1 | a | 1/2/2017 |
| 2 | a | 1/2/2017 |
| 3 | a | 2/2/2017 |
| 4 | b | 1/2/2017 |
| 5 | b | 1/2/2017 |
| 6 | b | 2/2/2017 |
| 7 | b | 3/2/2017 |
| 8 | b | 3/2/2017 |
+----+------+----------+
The result needs to be:
+------+----------+--------+
| type | date | amount |
+------+----------+--------+
| a | 1/2/2017 | 2 |
| a | 2/2/2017 | 1 |
| b | 1/2/2017 | 2 |
| b | 2/2/2017 | 1 |
| b | 3/2/2017 | 2 |
+------+----------+--------+
I already tried some queries with GROUP BY and DISTINCT but I can't figure out how to get no duplicates.
I already tried:
SELECT date, type, count(*) FROM table GROUP BY date, type
but that gives me duplicate date/type combinations. This is what it returns: