Sum duplicate row values
我正在尝试将其中两行的值相加,这些行具有重复值,我的表格如下:
表名(客户)
1 2 3 4 5 | VALUE years total 1 30 30 3 10 10 4 15 15 4 25 25 |
理想情况下,我最终会:
1 2 3 4 | VALUE years total 1 30 30 3 10 10 4 40 40 |
我已经尝试使用
1 2 3 4 5 6 7 8 9 10 | SELECT DISTINCT VALUE, years, SUM(customer.years) AS total FROM customer INNER JOIN LANGUAGE ON customer.expert=LANGUAGE.l_id GROUP BY expert, years; |
但是这会产生第一个表的副本,欢迎任何输入。 谢谢!!!
1 2 3 4 5 6 | SELECT VALUE, SUM(years) AS years, SUM(total) AS total FROM customers GROUP BY VALUE; |
你想要年份的总和和总和的总和,每个— 按—分组 值。
1 2 3 4 5 6 7 8 9 10 11 12 13 | SELECT VALUE, years, SUM(customer.years) AS total FROM (SELECT DISTINCT VALUE, years, customer.years AS total FROM customer INNER JOIN LANGUAGE ON customer.expert=LANGUAGE.l_id ) AS TABLECUS GROUP BY expert, years; |