[英]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
.按Province
和CustomerName
排序,描述您可以使用的算法,该算法将 output 每个CustomerName
和SalesValue
与每个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.