存储过程编写问题
场景:
1410500000000018011
2410500000000018041
3410500000000018031
4410500000000018051
5410500000000018142
6410500000000018112
7410500000000018111
841050000000001814
9410500000000018845
10410500000000018832
11410500000000018821
12410500000000018910
目标:
14105000000000180 11 41 31 51
54105000000000181 42 12 11 4
9 4105000000000188 45 32 21
12 4105000000000189 10
注:不是拼接,是行转列,数据很多,分组很多,所以需要用存储过程解决,
11 41 31 51 '' ''
42 12 11 4 '' ''
45 32 21 '' '' ''
10 '' '' '' '' ''
这个最多六列,没有数据的为空
请高人帮忙解答,谢谢
[解决办法]
ms不需要存储过程,用wm_concat函数就可以实现
create table t(id int, x int, y int);
insert into t values (1, 4105000000000180, 11);
insert into t values (2, 4105000000000180, 41);
insert into t values (3, 4105000000000180, 31);
insert into t values (4, 4105000000000180, 51);
insert into t values (5, 4105000000000181, 42);
insert into t values (6, 4105000000000181, 12);
insert into t values (7, 4105000000000181, 11);
insert into t values (8, 4105000000000181, 4);
insert into t values (9, 4105000000000188, 45);
insert into t values (10, 4105000000000188, 32);
insert into t values (11, 4105000000000188, 21);
insert into t values (12, 4105000000000189, 10);
commit;
select min(id), wm_concat(y) from t group by x;
存储过程编写有关问题
存储过程编写问题场景:141050000000001801124105000000000180413410500000000018031441050000000001805154
