user1916224 user1916224 - 1 year ago 75
SQL Question

count using inner join from 2 tables

I have 2 tables

and the other is
table has all the documents stored but which type of document it is, is defined in
, so i need help with the query which will help me find the count of the documents of each type in the document table.

columns under document_type_de table

ID, display name

columns under document table


Answer Source

This'll do it:

SELECT Type.[Display Name], 
       COUNT(*) AS [Number of Documents]
FROM Document_type_de Type
JOIN Document D
    ON Type.ID = D.documenttypede
GROUP BY Type.[Display Name]
ORDER BY Type.[Display Name]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download