代码如下:–创建 test 表 ,插入数据CREATE TABLE test(code varchar(50), [values] varchar(10),[count] int)INSERT test SELECT ‘001’, ‘aa’,1UNION ALL SELECT ‘001’, ‘bb’,2UNION ALL SELECT ‘002’, ‘aaa’,4UNION ALL SELECT ‘002’, ‘bbb’,5UNION ALL SELECT ‘002’, ‘ccc’,3; –方法