我试图以这样一种方式显示表中的记录,即它们根据列中的第一个单词(文本)进行分组和计数。
我的 SQL Server 表如下所示:
BinID BinName
2070 (for item PMI-67281)
3078 1 (for item PMI-14233)
2914 1 (for item PMI-1600537)
5272 1702 (for item 004908A)
5004 1702 (for item 0332002225BLK)
4019 1702 (for item 0332204204)
1208 1A1 (for item BWB2)
1662 1A1 (for item BWB27)
1212 1A1 (for item BWB31)
1213 1A1 (for item BWB35-S)
2583 1A2 (for item BWBT359)
1234 1A2 (for item BWBT364)
1266 1A3 (for item BWB1438)
2418 1A5 (for item 1006101)
2008 1A5 (for item 107794X)
1281 1ATOP (for item BWPA3493)
1218 1B1 (for item BWB161-S)
我需要的结果如下:
BinID BinName Count
5272 1702 (for item 004908A)
5004 1702 (for item 0332002225BLK)
4019 1702 (for item 0332204204) 3
1208 1A1 (for item BWB2)
1662 1A1 (for item BWB27)
1212 1A1 (for item BWB31)
1213 1A1 (for item BWB35-S) 4
2583 1A2 (for item BWBT359)
1234 1A2 (for item BWBT364) 2
1266 1A3 (for item BWB1438) 1
2418 1A5 (for item 1006101)
2008 1A5 (for item 107794X) 2
1281 1ATOP (for item BWPA3493) 1
1218 1B1 (for item BWB161-S) 1