Created
July 24, 2013 11:01
-
-
Save hemju/6069662 to your computer and use it in GitHub Desktop.
Shows two queries to get the word count and character count of a string/text column in Postgres.
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
# Character count | |
select sum(length(YOUR_COLUMN)) from YOUR_TABLE; | |
# Word count | |
select sum(array_length(regexp_split_to_array(YOUR_COLUMN, '\s'),1)) from YOUR_TABLE; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment