在特定分类中,有条件地创建了主题

我尝试为在满足某些条件的特定类别中创建了新主题的用户执行此操作。

SELECT DISTINCT ON (p.user_id) p.user_id, p.id post_id, p.created_at granted_at
FROM posts p
INNER JOIN topics t
ON p.topic_id=t.id
WHERE t.category_id = 99 AND p.post_number=1 AND  <conditions here> AND
  (:backfill OR p.id IN (:post_ids) )