trying to come up with a query and its doing my head in!
I have two tables.
Table A is full of rows of facts about a country including a column for capital city and one for total population.
Table B has list of cities their corresponding country and population of said city.
I need to do a query to to return a table basically from TABLE A showing the percentage population of that capital city against the total. Including Country Name, Capital City Name and % Population
This is in PostgreSQL by the way.
I was thinking along the lines of
SELECT CountryName.Table A, CityName.Table A, (Population.TableB/Population.TableA) AS percentage
From TableA, Table B;
Well it doesnt work! I guess I have to somehow make a link between the two cities somehow. A where statement? Arrrg.
Anyone any good with this? rumour has it @n0tch might be?