Share this post

Link to post

Share on other sites

If I'm reading your question correctly, you're going to want to look into the GROUP BY clause. Something along the lines of

SELECT a.city_name
,SUM(b.citizens) AS numCitizens
FROM table1 a
LEFT JOIN table2 b
ON a.cityID = b.cityID
GROUP BY numCitizens

No guarantee this will work if you copy and paste it (I'm only on my second up of coffee this morning), but it should get you moving in the right direction. Also, note that this assumes a foreign key of cityID in both table1 and table2 which you use to make the join.

Share this post

Link to post

Share on other sites

If I'm reading your question correctly, you're going to want to look into the GROUP BY clause. Something along the lines of

SELECT a.city_name
,SUM(b.citizens) AS numCitizens
FROM table1 a
LEFT JOIN table2 b
ON a.cityID = b.cityID
GROUP BY numCitizens

No guarantee this will work if you copy and paste it (I'm only on my second up of coffee this morning), but it should get you moving in the right direction. Also, note that this assumes a foreign key of cityID in both table1 and table2 which you use to make the join.

Well, thank you Max, I will give a try and let you know If I am on the right way... Thanks, and enjoy your second coffee