Skip to content

Instantly share code, notes, and snippets.

@ailabs-software
Created August 6, 2013 16:50
Show Gist options
  • Save ailabs-software/6166301 to your computer and use it in GitHub Desktop.
Save ailabs-software/6166301 to your computer and use it in GitHub Desktop.
presidentuncletom=# SELECT name, ARRAY(SELECT (title, id) FROM groups_map RIGHT OUTER JOIN
groups ON (groups_map.group_id = groups.id) WHERE groups_map.item_id=person.id)
AS groups FROM person;
name | groups
-----------------+----------------------------------------------------
Harley Earl | {}
Henry Ford | {"(\"industry mogul\",1)","(\"capital mogul\",2)"}
Rick Wagoner | {}
Alfred P. Sloan | {"(\"industry mogul\",1)","(\"capital mogul\",2)"}
Bob Eaton | {}
Howard Shultz | {}
Warren Buffet | {}
Jamie Dimon | {}
Michael Eisner | {}
Charlie Munger | {}
Lee Iacocca | {}
Bob Lutz | {}
Fritz Henderson | {}
Ken Chennault | {}
Lew Wasserman | {"(\"industry mogul\",1)"}
(15 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment