> For the complete documentation index, see [llms.txt](https://query.docs.doyto.win/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://query.docs.doyto.win/basic/aggregate-client.md).

# Complex Query

`AggregateClient` is used to execute complex queries.

## Example

```java
@AllArgsConstructor
@JsonBody
@RestController
public class UserAggregateController {

    private AggregateClient aggregateClient;

    @GetMapping("user/queryCountOfEachLevel")
    public List<UserLevelCountView> queryCountOfEachLevel(UserLevelHaving query) {
        return aggregateClient.query(UserLevelCountView.class, query);
    }

}
```

Refer [View Object](/object-concepts/view-object.md) to learn how to define a view object.
