Created
May 18, 2015 05:44
-
-
Save knmkr/ae696fd70d600d9c8577 to your computer and use it in GitHub Desktop.
Sort and uniq example in PostgreSQL with intarray extension.
This file contains hidden or 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 EXTENSION intarray; | |
SELECT uniq(sort(ARRAY[3,2,1,4,3])); | |
-- uniq | |
-- ----------- | |
-- {1,2,3,4} | |
SELECT unnest(uniq(sort(ARRAY[3,2,1,4,3]))); | |
-- unnest | |
-- -------- | |
-- 1 | |
-- 2 | |
-- 3 | |
-- 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment