我有一个数据集,我必须在MySQL中执行SUM(),但有3个GROUP BY级别。我已经尝试过了,但我可以得到结果。我在这里搜索过,但我找不到任何合适的解决方案。这是数据......
html, body {
overflow: scroll;
}
我需要按+---------+----------+---------+------+
| dev_id | skill | customer| vote |
+---------+----------+---------+------+
| 1 | .Net | Walmart | 0 |
| 1 | .Net | Walmart | 1 |
| 1 | .Net | Walmart | 1 |
| 1 | .Net | Walmart | 0 |
| 1 | .Net | Target | 0 |
| 1 | .Net | Target | 1 |
| 1 | .Net | Target | 1 |
| 1 | .Net | Target | 0 |
| 1 | Python | Walmart | 0 |
| 1 | Python | Walmart | 0 |
| 1 | Python | Walmart | 1 |
| 1 | Python | Walmart | 0 |
| 1 | Python | Target | 0 |
| 1 | Python | Target | 0 |
| 2 | .Net | Walmart | 0 |
| 2 | .Net | Walmart | 0 |
| 2 | .Net | Walmart | 0 |
| 2 | .Net | Walmart | 0 |
| 2 | .Net | Target | 0 |
| 2 | .Net | Target | 0 |
| 2 | .Net | Target | 1 |
| 2 | .Net | Target | 0 |
| 2 | Python | Walmart | 0 |
| 2 | Python | Walmart | 0 |
| 2 | Python | Walmart | 0 |
| 2 | Python | Walmart | 0 |
| 2 | Python | Target | 0 |
| 2 | Python | Target | 1 |
+---------+----------+---------+------+
分组,然后按dev_id
分组,然后按skill
分组,customer
分组。渴望的解决方案是这样的......
SUM()
关于如何解决这个问题的任何想法?
答案 0 :(得分:1)
您是否尝试过以下查询:
select dev_id, skill, customer, sum(vote) as cnt from <table name> group by dev_id, skill, customer;