我有 1 个表,我想查询特定列。Aa -> 是不同的,
Bb -> Sum B 按 Aa 进行的总分组,
Cc -> 特定 Aa 的最小值 C,
Bb1,Dd -> C 最小时的 B,D 值,
Ee -> 不同的
表格1
id | A | B | C | D | E |
------------------------
1 | 2 | 1 | 2 | 1 | A |
2 | 2 | 2 | 7 | 0 | A |
3 | 4 | 1 | 7 | 3 | B |
4 | 4 | 0 | 5 | 4 | B |
结果
Aa | Bb | Cc | Bb1 | Dd | Ee |
-----------------------------
2 | 3 | 2 | 1 | 1 | A |
4 | 1 | 5 | 0 | 4 | B |
我的查询给出错误的结果
SELECT
test.A as Aa,
SUM(test.B) as Bb,
min(test.C) as Cc,
test.D as Dd,
test.E as Ee
FROM `test`
group by A,E