我是 SQL Server 的新手,遇到了一个令我困惑的问题。
我有 2 个数据表Category
和Product
. 下面是详细的表格。
类别:
------------------------------------------------------
categoryId | categoryName | desc
------------------------------------------------------
1 | Shirt | Men's Shirt
2 | Jeans | Men's Pants
3 | Accessories | Women's Accessories
------------------------------------------------------
产品
---------------------------------------------------------------
productID | desc | categoryId
---------------------------------------------------------------
1 | Slim-fit Classic Shirt | 1
2 | Denim Slim-fit jeans | 2
3 | Denim Regular-fit jeans | 2
4 | Bracelet | 3
---------------------------------------------------------------
我怎样才能得到如下的确切输出?
-------------------------------------------------------------------
categoryId | categoryName | numOfRecord | desc
-------------------------------------------------------------------
1 | Shirt | 1 | Men's Shirt
2 | Jeans | 2 | Men's Pants
3 | Accessories | 1 | Women's Accessories
-------------------------------------------------------------------
对不起我的英语不好。