Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. SELECT
  2. title,
  3. array_remove(array_agg(
  4. CASE WHEN type=ANY(ARRAY['author', 'poet', 'translator']) THEN fullname) ELSE NULL END
  5. ORDER BY array_position(ARRAY[
  6. 'author', 'poet', 'translator'
  7. ], type)
  8. ), NULL) as authors
  9. FROM books
  10. GROUP BY title
  11. ORDER BY authors ASC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement