Share via

Adding an equation when using join and sum.

AUBREY MCINTYRE 40 Reputation points
2025-09-24T17:12:49.15+00:00

Screenshot 2025-09-24 115559

Name from jurisdiction and reported covid cases from covid cases has to be joined. Picture is expected output.

I am only getting the names and not any data?

SQL Server Database Engine
{count} votes

Answer recommended by moderator
  1. JAMESKATTOOR-0859 0 Reputation points
    2025-10-01T11:38:40.3533333+00:00

    Three things:

    1. In your WHERE clause, instead of "cc.calenderdate = 2021", you should use "YEAR(cc.calendardate) = 2021".
    2. 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.
    3. Add population to the group by, i.e., group by j.name, j.Population.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.