add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
WITH result_T AS (
SELECT 1 AS vocabId, 1 AS docId, 1000 AS count, 'plane' AS word UNION ALL
SELECT 1, 3, 100, 'plane' UNION ALL
SELECT 3, 1, 1200, 'motorbike' UNION ALL
SELECT 3, 2, 702, 'motorbike' UNION ALL
SELECT 3, 3, 600, 'motorbike' UNION ALL
SELECT 5, 3, 2000, 'boat' UNION ALL
SELECT 5, 2, 200, 'boat'
)

SELECT
r1.word,
r2.word,
COUNT(*) AS cnt
FROM result_T r1
INNER JOIN result_T r2
ON r1.word < r2.word AND
r1.docId = r2.docId
GROUP BY
r1.word,
r2.word
ORDER BY
COUNT(*) DESC;




word word cnt
boat motorbike 2
motorbike plane 2
boat plane 1