How do I find the month with the most crime in every year and the number only of the crimes in that month of that year using SQL in Microsoft Access?
I tried this, hoping it would give me the result I wanted.
SELECT COUNT(*) AS CRIME_COUNT, CRIME_MONTH, CRIME_YEAR
FROM CRIMEDATA
GROUP BY CRIME_YEAR, [DISTINCT CRIME_MONTH], CRIME_MONTH
ORDER BY COUNT(*) DESC
It prompted me to enter a parameter value for [distinct crime_month]
, so I just entered 1, and I got a table with the rows ordered by descending crime counts and the corresponding months and years, but it showed every month in every year. I get the same result not using [distinct crime_month]
. How can I get the result I'm looking for?