• Something like this?

    SELECT ID, Name, Type, CountType = COUNT(Type)

    FROM Table1 t1 INNER JOIN Table2 t2 ON t1.Type = t2.Type

    GROUP BY ID, Name, Type

    This code is a best guess, as there's not much information in your question to start from.

    Please read the first link in my signature on how to post questions on a forum. It explains how to post table DDL and how to post sample data.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP