の中の
◦ 作成者
◦ 確認者
• を拾ってきて「誰がたくさん依頼を出して いるか」「誰にレビューがよっているか」を 集計できます
SELECT id, name, tags, reviewee, reviewer, link, COUNT(1) OVER() AS total_query_num FROM ( SELECT queries.id, queries.name, STRING_AGG(tag, ',') AS tags, users.name AS reviewee, REGEXP_MATCHES(query, '\*\s?確認者:\s?([^\n]*)') AS reviewer, CONCAT('<a href="https://myredashdomain.jp/queries/', queries.id, '/source">LINK</a>') AS link FROM queries CROSS JOIN UNNEST(tags) AS tag INNER JOIN users ON user_id = users.id WHERE NOT is_archived AND ( query LIKE '%reviewing%' OR tag = 'reviewing' ) GROUP BY queries.id, queries.name, reviewee, reviewer, link ) AS queries