Sqlserver
 sql >> Base de données >  >> RDS >> Sqlserver

Obtenir le nombre de tables sql

Essayez ceci :

BEGIN


SELECT     tbl_SubCategory.Name AS SubCategoryName, COUNT(*) AS TotalCompanies
FROM       tbl_Category INNER JOIN
                      tbl_Company_Category_Map ON tbl_Category.Id = tbl_Company_Category_Map.CategoryId INNER JOIN
                      tbl_SubCategory ON tbl_Company_Category_Map.SubCategoryId = tbl_SubCategory.Id
WHERE     (tbl_Company_Category_Map.CategoryId = @Id)
Group By tbl_SubCategory.Name
ORDER BY tbl_SubCategory.Name

END