简体   繁体   English

我应该使用哪个 SQL 查询?

[英]Which SQL query should I use?

Given a list containing给定一个包含

Province, CustomerName, SalesValue

sorted by Province and CustomerName , describe an algorithm you could use that would output each CustomerName and SalesValue with the total SalesValue per Province .ProvinceCustomerName排序,描述您可以使用的算法,该算法将 output 每个CustomerNameSalesValue与每个Province的总SalesValue

You could first create a temporary table temp_table from your table list and use than GROUP BY .您可以先从表list创建一个临时表temp_table并使用GROUP BY

SELECT CustomerName, Province, Sum(SalesValue) from list A
  INNER JOIN temp_table B 
  ON A.CustomerValue = B.CustomerValue
  GROUP BY CustomerName, Province

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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