-
Notifications
You must be signed in to change notification settings - Fork 8.3k
RFC: Fractional LIMIT #81892
Copy link
Copy link
Closed
Labels
Description
Company or project name
ClickHouse
Use case
Taking records from the middle of the resultset of unknown size, to simplify some analytic scenarios.
Describe the solution you'd like
Fractional values in the 0..1 interval will represent quantiles of the resultset instead of fixed numbers of elements.
Example:
SELECT * FROM table ORDER BY x LIMIT 0.1; -- returns first 10% of the result
SELECT * FROM table ORDER BY x LIMIT 0.5, 0.25; -- returns 3rd quartile of the result
SELECT * FROM table ORDER BY x LIMIT 0.5, 1; -- returns a single record, which is the median of the result
Describe alternatives you've considered
Instead of using fractions, we can introduce a % syntax specifically for LIMIT. But it would be less composable with constant expressions and aliases.
Additional context
No response
Reactions are currently unavailable