SELECT s.tags FROM (SELECT sub.tags ,COUNT(1) as post_count

0

Please login or register to vote for this query.

(click on this box to dismiss)

Drupal Answers

Q&A for Drupal developers and administrators

SELECT s.tags FROM (SELECT sub.tags
    ,COUNT(1) as post_count
    ,row_number() over (order by COUNT(1) DESC) rn
  FROM (SELECT pt.postid
      ,STRING_AGG(t.tagname, ', ') WITHIN GROUP(ORDER BY t.tagname) as tags
    FROM tags t
      JOIN posttags pt
        ON t.id = pt.tagid
    GROUP BY pt.postid
    HAVING COUNT(*) >=2    
    ) sub
  GROUP BY sub.tags
) s
WHERE s.rn = 1;

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results