Last active
October 4, 2018 13:38
-
-
Save mistificator/5b11909e3e8ee1305afc31984992acf0 to your computer and use it in GitHub Desktop.
Accum in array with relation values got from SELECT
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
SELECT DISTINCT | |
schedule_groups.id, | |
schedule_groups.description, | |
schedule_groups.groups_id, | |
array_agg(groups.id), | |
array_to_string( | |
ARRAY( | |
SELECT DISTINCT * FROM unnest( | |
array_accum( | |
ARRAY( | |
SELECT kls_modes.short_name_rus | |
FROM kls_modes | |
WHERE kls_modes.id = ANY(groups.work_mode_id) | |
) | |
) | |
) | |
), | |
', ') | |
FROM schedule_groups | |
INNER JOIN groups ON groups.id = ANY(schedule_groups.groups_id) | |
GROUP BY schedule_groups.id ORDER BY schedule_groups.id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment