Skip to content

Issue on docs #2312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
nzzl6 opened this issue Apr 22, 2025 · 2 comments
Open

Issue on docs #2312

nzzl6 opened this issue Apr 22, 2025 · 2 comments

Comments

@nzzl6
Copy link

nzzl6 commented Apr 22, 2025

Path:/zh-CN/docs/sql-manual/sql-functions/aggregate-functions/min-by

+------+------+------+------+
| k1 | k2 | k3 | k4 |
+------+------+------+------+
| 0 | 3 | 2 | 100 |
| 1 | 2 | 3 | 4 |
| 4 | 3 | 2 | 1 |
| 3 | 4 | 2 | 1 |
+------+------+------+------+

select min_by(k1, k4) from tbl;

+--------------------+
| min_by(k1, k4) |
+--------------------+
| 4 |
+--------------------+

如何得出最小的k4对应的最小的k1,如上就是得出3?

@KassieZ
Copy link
Contributor

KassieZ commented Apr 23, 2025

正在和社区技术支持同学确认问题,后续如果有疑问可前往 Doris 中文技术论坛 提问,有专人支持解答

@yuanyuan8983
Copy link
Contributor

min_by的最小值和关联值相关联,如果最小值有多个,那么会返回第一个最小值的关联值,如果这个用法不满足场景,可以通过窗口函数 ROW_NUMBER 来明确排序规则,或者使用 min 函数作为过滤条件查询

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants