-
Notifications
You must be signed in to change notification settings - Fork 279
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
Quantile serias scalar function #2055
base: master
Are you sure you want to change the base?
Conversation
## Description | ||
The `QUANTILE_PERCENT` function is used to calculate the quantile value for a given percentage. It takes two parameters: a quantile_state column and a constant floating-point number representing the percentage. The function returns a floating-point number that represents the quantile value at the given percentage position. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
章节之间加上空行,防止渲染错误
``` | ||
QUANTILE_PERCENT(<quantile_state>, <percent>) | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
``` | |
QUANTILE_PERCENT(<quantile_state>, <percent>) | |
``` | |
```sql | |
QUANTILE_PERCENT(<quantile_state>, <percent>) | |
``` |
SELECT dt, id, quantile_percent(quantile_union(price), 0) FROM quantile_state_agg_test GROUP BY dt, id ORDER BY dt, id | ||
-------------- | ||
|
||
+----------+------+--------------------------------------------+ | ||
| dt | id | quantile_percent(quantile_union(price), 0) | | ||
+----------+------+--------------------------------------------+ | ||
| 20220201 | 0 | 1 | | ||
| 20220201 | 1 | -1 | | ||
+----------+------+--------------------------------------------+ | ||
2 rows in set (0.42 sec) | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SELECT dt, id, quantile_percent(quantile_union(price), 0) FROM quantile_state_agg_test GROUP BY dt, id ORDER BY dt, id | |
-------------- | |
+----------+------+--------------------------------------------+ | |
| dt | id | quantile_percent(quantile_union(price), 0) | | |
+----------+------+--------------------------------------------+ | |
| 20220201 | 0 | 1 | | |
| 20220201 | 1 | -1 | | |
+----------+------+--------------------------------------------+ | |
2 rows in set (0.42 sec) | |
``` | |
SELECT dt, id, quantile_percent(quantile_union(price), 0) FROM quantile_state_agg_test GROUP BY dt, id ORDER BY dt, id | |
``` | |
```text | |
+----------+------+--------------------------------------------+ | |
| dt | id | quantile_percent(quantile_union(price), 0) | | |
+----------+------+--------------------------------------------+ | |
| 20220201 | 0 | 1 | | |
| 20220201 | 1 | -1 | | |
+----------+------+--------------------------------------------+ | |
``` |
```sql | ||
-------------- | ||
select quantile_percent(quantile_union(quantile_state_empty()), 0) | ||
-------------- | ||
|
||
+-------------------------------------------------------------+ | ||
| quantile_percent(quantile_union(quantile_state_empty()), 0) | | ||
+-------------------------------------------------------------+ | ||
| NULL | | ||
+-------------------------------------------------------------+ | ||
1 row in set (0.12 sec) | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
按照 quantile-percent 评论中的统一改一下 example 格式
- 查询和结果要分开
- 结果用 text 格式
- 不要最后一行
x rows...
Versions
Languages
Docs Checklist