---
document_id: agent.dataset.tmall.task.aggregate_drilldown
schema_version: 1
---

<!-- Generated by scripts.build_agent_guide; do not edit. -->

# Aggregate and product drilldown / 汇总与商品下钻

Query an aggregate scope, then rank products under exactly the same filters.

先查询汇总范围，再在完全相同的筛选条件下对商品下钻排序。

## Required inputs / 必要输入

- `scope` — `search_values`; required (`category_l3`): Exact category value
  精确品类值
- `time` — `user_required`; required: Analysis time range
  分析时间范围
- `ranking_metric` — `user_required`; optional; default `gmv`; allowed: `gmv, units`: Metric used to rank products
  商品排名所用指标
- `top_n` — `user_required`; optional; default `20`: Number of products to return
  返回商品数量

## Steps / 步骤

1. `resolve_scope` · `search_values` — Resolve the spoken category value.
   对齐用户口语中的品类值。
   - search `category_l3` with `${scope}`
2. `query_scope` · `query_metrics` — Query aggregate GMV and units.
   查询汇总销售额和销量。
   - bundle: `aggregate_and_products` (one `query_metrics` call)
   - metrics: `gmv`, `units`
   - filters: `category_l3 eq ${scope}`
   - time: `${time}`
3. `query_products` · `query_metrics` — Query products using the same scope and time.
   使用相同范围和时间查询商品。
   - bundle: `aggregate_and_products` (one `query_metrics` call)
   - metrics: `gmv`, `units`
   - group_by: `product_id`, `title`, `product_url`
   - result entity: `product`
   - filters: `category_l3 eq ${scope}`
   - time: `${time}`
   - order_by: `${ranking_metric}` desc
   - limit: `${top_n}`

## Agent computation / Agent 计算

- `rank_products` · `rank` from `query_products` — Rank products by the requested metric.
  按用户要求的指标对商品排序。

## Output requirements / 输出要求

- Show the aggregate before the product ranking, with complete product identity.
  先展示汇总结果，再展示包含完整商品身份的商品排名。

## Limitations / 限制

- Keep the aggregate and drilldown filters identical.
  汇总与下钻必须使用相同筛选条件。

## Stop conditions / 停止条件

- Stop if the scope cannot be resolved exactly.
  无法精确对齐范围时停止并追问。
