[英]Consider values from multiple columns into 1 final output
Requirement:要求:
(Related to: MySQL) (相关:MySQL)
I have set of unique names in column A, then column B,.. with each column containing a unique product.我在 A 列中有一组唯一的名称,然后是 B 列,.. 每列包含一个唯一的产品。 Eg.
例如。 enter image description here
在此处输入图像描述
I expect an output, that considers the total of all Columns, under 1 single header and outputs something like this: enter image description here我期待一个 output,考虑所有列的总数,在 1 个 header 下并输出如下内容:在此处输入图像描述
Is this possible?这可能吗? How do I go about that?
我怎么go一下呢?
Thank you!谢谢!
Not really sure how to go about this.不太确定如何与 go 联系。 Would concat/ Union work here?
concat/Union 会在这里工作吗?
select person, sum(item) from
(SELECT person_1 as person, shoes as item from YOURTABLE
union SELECT person_2 as person, watches as item from YOURTABLE
union SELECT person_3 as person, clothes as item from YOURTABLE)
temp group by person
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.