Created
December 3, 2019 12:22
-
-
Save klapuch/23d24cbe6139912ae3d9f8e1b7b3a0df to your computer and use it in GitHub Desktop.
array_reverse function for postgres
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 FUNCTION array_reverse(anyarray) RETURNS anyarray RETURNS NULL ON NULL INPUT AS | |
$BODY$ | |
SELECT array_agg(result.value ORDER BY ordinality DESC) FROM unnest($1) WITH ORDINALITY AS result(value); | |
$BODY$ | |
LANGUAGE sql IMMUTABLE; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment