Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- title,
- array_remove(array_agg(
- CASE WHEN type=ANY(ARRAY['author', 'poet', 'translator']) THEN fullname) ELSE NULL END
- ORDER BY array_position(ARRAY[
- 'author', 'poet', 'translator'
- ], type)
- ), NULL) as authors
- FROM books
- GROUP BY title
- ORDER BY authors ASC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement