commento/db/20180923004309-comment-count-build.sql
2018-09-23 00:47:38 -04:00

11 lines
224 B
SQL

-- Build the comments count column
UPDATE pages
SET commentCount = subquery.commentCount
FROM (
SELECT COUNT(commentHex) as commentCount
FROM comments
WHERE state = 'approved'
GROUP BY (domain, path)
) as subquery;