Created
April 25, 2012 21:37
-
-
Save mozz100/2493717 to your computer and use it in GitHub Desktop.
Shakespeare PGSQL queries
This file contains 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
-- 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See https://postgres.heroku.com/dataclips/ljfeywbwtxbcabardaxvcstjyodi for the results of this query