简体   繁体   中英

Sql query to get Total in columns

whats the SQL Query to get the final row?

Region   Country        City    Population

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

Using TSQL, you can try:

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

'Table is your Table Name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM