我目前有一个SQL查询,它返回每周在一个类别中创建的主题数。
SELECT
COUNT(*) AS topic_count,
DATE_TRUNC('week', created_at) AS week
FROM topics
WHERE
topics.deleted_at IS NULL AND
topics.category_id = (
SELECT id
FROM categories
WHERE categories.name LIKE 'Category Name'
)
GROUP BY DATE_TRUNC('week', created_at)
ORDER BY week DESC
如何更改此查询以便我可以在类别表中看到每个类别的topic_count?我希望看到的结果列是:
答案 0 :(得分:1)
除了星期之外,还要将类别名称添加到查询和分组中:
var contents = fs.readFileSync(("dererlkoenig"), 'utf8');
console.log(contents);