我有两张表 Business 和 BusinessCat。我需要一个 MSSQL 查询,它会得到以下结果:
ID | CategoryName | RecordCount
1 | Local | 3
2 | National | 1
3 | International| 2
4 | Other | 0
我需要计算每个类别中有多少作为另一列。
业务表如下所示:
ID | Category | BusinessName
1 | 3 | Blackstone, Inc.
2 | 2 | Pet Smart
3 | 1 | John Doe
4 | 3 | Best Buy
5 | 1 | Sams Treats
6 | 1 | Eastcoast Tattoo
BusinessCat 表如下所示:
ID | CategoryName
1 | Local
2 | National
3 | International
4 | Other