ahmed elbarbary

ahmed elbarbary

  • NA
  • 1.6k
  • 275k

How to get value portion key to every rn from 1 to 3 row on one row?

Jan 26 2021 9:11 AM
I need to get value portion key to every 3 row on one row meaning
rn 1,2,3 one row KRM__21X0E100C0ADD
rn 1,2,3 one row KRM__21X0J100K0ADD
rn 1,2,3 on one row KRM__21X1C100D0ADD
  1. create table #portiontableFinal  
  2. (  
  3. rn int,  
  4. ValuePortionKey nvarchar(100)  
  5. )  
  6. insert into #portiontableFinal(rn,ValuePortionKey)  
  7. values  
  8. (1,'KRM__21X0E100'),  
  9. (2,'C0AD'),  
  10. (3,'D'),  
  11. (1,'KRM__21X0J100'),  
  12. (2,'K0AD'),  
  13. (3,'D'),  
  14. (1,'KRM__21X1C100'),  
  15. (2,'D0AD'),  
  16. (3,'D')  
  17. RN  ValuePortionKey  
  18. 1   KRM__21X0E100  
  19. 2   C0AD  
  20. 3   D  
  21. 1   KRM__21X0J100  
  22. 2   K0AD  
  23. 3   D  
  24. 1   KRM__21X1C100  
  25. 2   D0AD  
  26. 3   D  
I need to get from 1 to 3 on one rows as following :
final result I need to get as below :
KRM__21X0E100C0ADD
KRM__21X0J100K0ADD
KRM__21X1C100D0ADD

Answers (8)