diff --git a/postgres/word-count-for-a-column.md b/postgres/word-count-for-a-column.md index 11d0d9f..b38c41d 100644 --- a/postgres/word-count-for-a-column.md +++ b/postgres/word-count-for-a-column.md @@ -2,7 +2,7 @@ Assuming I have a database with a posts table: -``` +```sql > select * from posts where id = 1; id | title | content ----+----------+------------------------------------ @@ -11,7 +11,7 @@ Assuming I have a database with a posts table: I can compute the word count of the content of a given post like so: -``` +```sql > select sum(array_length(regexp_split_to_array(content, '\s+'), 1)) from posts where id = 1; sum -----