# 分组映射

对于`GROUP BY`子句，通常分组字段也需要出现在返回列中，可通过在视图类字段上添加注解声明其为分组列，并在映射时添加到`GROUP BY`后。

**示例**

定义视图对象时，在用于分组的字段上添加`@GroupBy`注解：

```java
@GroupBy
private int returnFlag;

@GroupBy
private int lineStatus;
```

带有`@GroupBy`注解的字段被映射为：

```sql
SELECT return_flag, line_status, ... FROM ...
GROUP BY return_flag, line_status ...
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://query.docs.doyto.win/zh/object-concepts/view-object/group-by.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
