I have a table with date and kind of issue. It looks like:
Date | Issue
2018-01-01 09:32:33.000 | Problem 1
2018-01-01 19:47:11.000 | Problem 1
2018-01-01 14:25:16.000 | Problem 2
2018-01-02 11:07:20.000 | Problem 1
2018-01-02 19:18:51.000 | Problem 2
2018-01-03 20:45:41.000 | Problem 1
2018-01-03 04:27:56.000 | Problem 1
2018-01-03 15:27:56.000 | Problem 2
2018-01-03 09:27:56.000 | Problem 2
2018-01-03 22:27:56.000 | Problem 3
I want to count the total amount of each problem for each day. I want it to look like:
Date | Issue | Amount
2018-01-01 | Problem 1 | 2
2018-01-01 | Problem 2 | 1
2018-01-02 | Problem 1 | 1
2018-01-02 | Problem 2 | 1
2018-01-03 | Problem 1 | 2
2018-01-03 | Problem 2 | 2
2018-01-03 | Problem 3 | 1
Now I have this, but obviously it doesn't work:
SELECT CONVERT(VARCHAR, CONVERT(DATE TIME, Date), 23) AS Date,
Issue,
COUNT(Date) AS Amount
FROM Issues
GROUP BY Date, Issue
ORDER BY Date, Issue
Thanks in advance.