saleemMSMS
11-09-2009, 11:46 PM
consider the following table
http://i35.tinypic.com/5o9m41.jpg
i want to query and take the total population and the number of GNs group by the district so i wrote the following query
SELECT District.DistrictName AS [District Name], Count(GN.GNCode) AS [Number of GNs], sum(population) AS [Total Polulation]
FROM (District INNER JOIN GN ON District.DisctrictCode=GN.DisctrictCode)
GROUP BY (District.DisctrictCode), District.DistrictName;
but now i want the percentage of population in each district.. can someone guide me towards the query? since theres a group by clause i'm unable to get the total population.. thats what is worrying.. any suggestions please ?
http://i35.tinypic.com/5o9m41.jpg
i want to query and take the total population and the number of GNs group by the district so i wrote the following query
SELECT District.DistrictName AS [District Name], Count(GN.GNCode) AS [Number of GNs], sum(population) AS [Total Polulation]
FROM (District INNER JOIN GN ON District.DisctrictCode=GN.DisctrictCode)
GROUP BY (District.DisctrictCode), District.DistrictName;
but now i want the percentage of population in each district.. can someone guide me towards the query? since theres a group by clause i'm unable to get the total population.. thats what is worrying.. any suggestions please ?