Created
May 7, 2016 20:37
-
-
Save iangow/4bc239486174330fd4d6b88d98bfe9f6 to your computer and use it in GitHub Desktop.
Function to add median aggregate to PostgreSQL (requires PL/R)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE AGGREGATE public.median(double precision) ( | |
SFUNC=public.plr_array_accum, | |
STYPE=float8[], | |
FINALFUNC=r_median | |
); | |
CREATE OR REPLACE FUNCTION public.r_median(double precision[]) | |
RETURNS double precision AS | |
$BODY$ | |
median(arg1) | |
$BODY$ LANGUAGE plr; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment