Posted By

stavelin on 04/26/09


Tagged

sql count length wordcount sum


Versions (?)

SQL word count


 / Published in: SQL
 

My texts are a combination of fields, this is arranged by adding them one by one.

  1. SELECT aid, published_date, header, published_state,
  2.  
  3. SUM(1+ LENGTH(introduction3) - LENGTH(REPLACE(introduction3, ' ','')))
  4. +
  5. SUM(1+ LENGTH(body) - LENGTH(REPLACE(body, ' ','')))
  6. +
  7. SUM(1+ LENGTH(outro3) - LENGTH(REPLACE(outro3, ' ','')))
  8. AS Wordcount
  9.  
  10. FROM article_tbl
  11. GROUP BY aid
  12. HAVING published_state = 1
  13. ORDER BY Wordcount DESC

Report this snippet  

You need to login to post a comment.