我遇到了 GROUP BY 子句的问题,并且数据没有像我想要的那样显示:
我有这样的数据:
-------------------------------------------------------------------
| Company | Division | Business Area | Unit | Name Full | ID |
-------------------------------------------------------------------
| Company 1 | Div 1 | Business 1 | Unit 1 | Customer 1 | 01 |
| Company 1 | Div 1 | Business 1 | Unit 1 | Customer 2 | 02 |
| Company 1 | Div 1 | Business 1 | Unit 2 | Customer 3 | 03 |
| Company 1 | Div 1 | Business 3 | Unit 3 | Customer 2 | 02 |
| Company 1 | Div 2 | Business 1 | Unit 1 | Customer 4 | 04 |
....
....
在 UI 中,我希望它像这样显示:
Company 1, Div 1, Business 1, Unit 1
-- Customer 1 01
-- Customer 2 02
Company 1, Div 1, Business 1, Unit 2
-- Customer 3 03
Company 1, Div 1, Business 3, Unit 3
-- Customer 2 02
Company 1, Div 2, Business 1, Unit 1
-- Customer 4 04
我尝试了查询,如果我尝试仅使用 company、div、business 和 unit 进行分组,则会收到错误:00979:not a group by expression 因为我没有使用 SELECT 中使用的所有列,但后来我没有得到我要求的结果。
知道我该如何进行吗?