简体   繁体   中英

MySQL how to get the total sum of a column one to one table using CMD

I'm doing a code for MySQL that can get all of the sum of one column except for the distinct value. So here is the picture. There are two tables that have to join in-order to get the sum of 2050, what'd be the syntax to get that sum?

在此输入图像描述

 Select region,sum(sales)
  from store_information,geography
  Group by region

Will give sales by geography. Now you can select required geography and saleAmount

Seems you need the sum for west

 Select sum(sales)
 from store_information
 LEFT JOIN geography on geography.store_name = store_information.store_name 
 where region = 'West'

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