-
Notifications
You must be signed in to change notification settings - Fork 171
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
Add support for quantile() #169
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@edavidaja that is perfect, thank you! |
A few more tweaks to make it a bit easier for me to parse: Aggregation function:
Window function:
|
For the databases that support the The SQL server docs seem to be the only place that addresses this problem and suggests using SELECT DISTINCT DepartmentName
,PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY BaseRate)
OVER (PARTITION BY DepartmentName) AS MedianCont
,PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY BaseRate)
OVER (PARTITION BY DepartmentName) AS MedianDisc
FROM dbo.DimEmployee; So maybe the best we can do is supply translations for those as window functions, and then suggest the user use |
Oops, those aren't window functions, but are "ordered-set aggregate" functions, and they work just fine with library(DBI)
con <- dbConnect(RPostgres::Postgres())
dbGetQuery(con, "
SELECT cyl, PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY mpg)
FROM mtcars
GROUP BY cyl
")
#> cyl percentile_cont
#> 1 4 26.0
#> 2 6 19.7
#> 3 8 15.2 Created on 2019-02-06 by the reprex package (v0.2.1.9000) |
Thanks @hadley! 🎉 |
Looks like the link to teradata was actually to teradata's distribution of presto. It seems like teradata actually is ansi compliant: https://docs.teradata.com/reader/756LNiPSFdY~4JcCCcR5Cw/RgAqeSpr93jpuGAvDTud3w |
Would it be possible to add support for the
quantile()
function?Quite a few databases support
PERCENTILE_CONT
andPERCENTILE_DISC
, which I think could make this possible (e.g. Google BigQuery, PostgreSQL, and Redshift).I'd be willing to help of course, but would need some pointers on where to start.
The text was updated successfully, but these errors were encountered: