Skip to content

Instantly share code, notes, and snippets.

@mozz100
Created April 25, 2012 21:37
Show Gist options
  • Save mozz100/2493717 to your computer and use it in GitHub Desktop.
Save mozz100/2493717 to your computer and use it in GitHub Desktop.
Shakespeare PGSQL queries
-- of all the characters, whose paragraphs/speeches are the longest, on average?
SELECT
"characters"."name" AS "character_name",
SUM(length("paragraphs"."plain_text")) as "letter_count",
COUNT(*) as "paragraph_count",
SUM(length("paragraphs"."plain_text"))/COUNT(*) as "drone_factor"
FROM "paragraphs"
INNER JOIN "characters" ON "paragraphs"."character_id" = "characters"."id"
GROUP BY "characters"."name"
ORDER BY "drone_factor" DESC
@mozz100
Copy link
Author

mozz100 commented May 2, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment