Sql查询获取列中的Total

时间:2014-02-25 22:04:33

标签: sql

SQL Query是否获得最后一行?

Region   Country        City    Population

Africa   Ghana          Accra   11200
Africa   Ghana          Nzma    1186
Africa   Ghana          Bole    160
Africa   Ghana          3       12546

2 个答案:

答案 0 :(得分:4)

使用TSQL,您可以尝试:

SELECT Region, Country, COUNT(City), SUM(Population) FROM TableName
GROUP BY Region, Country

答案 1 :(得分:0)

SELECT Table.Region, Table.Country, Sum(Table.[Population]) AS [Sum Population]
FROM Table
GROUP BY Table.Region, Table.Country;

'表是您的表名