[Solved] SQL Group by and intersect between internal columns [closed]


SELECT Category, Tag1Value
FROM table_name t1
WHERE EXISTS (SELECT 1 FROM table_name WHERE Tag2Value = t1.Tag1Value)

UPDATE

Try this :

SELECT res.Category, res.tag, COUNT(res.tag) 
FROM
    (SELECT DISTINCT Category, Tag1Value tag
    FROM table_name
    UNION ALL
    SELECT DISTINCT Category, Tag2Value tag
    FROM table_name) res
GROUP BY res.Category, res.tag
HAVING COUNT(res.tag)>1

It return :

category          |    tag
-----------------------------------
Industry          |    Insurance
Engagement Type   |    Micro Audit

4

solved SQL Group by and intersect between internal columns [closed]