From this, I have to return only the population count of the last day of the month, which I have written a query that returns the below result:
Returns: Population count with the last day of the month

Code is below:
SELECT
Country
, [City Abbr]
, [Area Code]
, [Date]
FROM [dbo].[Population]
WHERE [Date] IN (
SELECT MAX ([Date])
FROM [dbo].[Population]
GROUP BY MONTH ([Date])
, YEAR ([Date])
)
ORDER BY [Area Code];
- How to calculate the average for the whole month? I want to calculate the average temperature from the temperature column within the same population table and display it along with the population count from the last day of the month.
- I have another table called Dead.dbo, where the mortality is recorded daily. I have to get the total dead for the month and display it with the same population table result.
The final result must be the population count on the last day of the month, the average temperature of the whole month and the Sum of dead (From the Dead table).
Your help and guidance will help me.
Regards, NewB




The easiest way is to do subqueries.. I didn't copy all of your data since i couldn't copy it to begin with, but I made an easy query with similar columns/values that you may be able to figure it out of.
Depending on your keys for the tables you'll have to expand the where clause for (probably) country, area code etc..