Core component of SQL Server for storing, processing, and securing data
Three things:
- In your WHERE clause, instead of "cc.calenderdate = 2021", you should use "YEAR(cc.calendardate) = 2021".
- Change the line "SUM(cc.reportedcovidcases)..." to "SUM(cc.reportedcovidecases) * 1000.0 / j.Population". You need the population of the states in question. If the column is not "Population" change to whatever it is in the table.
- Add population to the group by, i.e., group by j.name, j.Population.