 @Cat2 + ',' + Col2 END;
GO

SELECT ID, Col3 = MAX(Col3) 
, Col4 = MAX(Col4)
FROM #Table1Concat
GROUP BY ID

Method 2: Add the concatenation columns directly to the original table and concatenate the new columns:
CREATE TABLE #Table1(ID INT, Col1 VARCHAR(1), Col2 VARCHAR(1), Col1Cat VARCHAR(MAX), Col2Cat VARCHAR(MAX));
GO

INSERT #Table1(ID,Col1,Col2) VALUES(1,'A','X'), (2,'B','Y'), (2,'C','Z');
GO

DECLARE @Cat1 VARCHAR(MAX) = '';
DECLARE @Cat2 VARCHAR(MAX) = '';
; WITH CTE AS (
    SELECT TOP 2147483647 t1.*, r = ROW_NUMBER()OVER(PARTITION BY t1.ID ORDER BY t1.Col1, t1.Col2)
    FROM #Table1 t1
    ORDER BY t1.ID, t1.Col1, t1.Col2
)
UPDATE CTE
SET @Cat1 = Col1Cat = CASE r WHEN 1 THEN ISNULL(Col1,'') ELSE @Cat1 + ',' + Col1 END
, @Cat2 = Col2Cat = CASE r WHEN 1 THEN ISNULL(Col2,'') ELSE @Cat2 + ',' + Col2 END;
GO

SELECT ID, Col1Cat = MAX(Col1Cat) 
, Col2Cat = MAX(Col2Cat)
FROM #Table1
GROUP BY ID;
GO

 Q:

Javascript Get childs nodes object with recursion

in the backend php server, i've a class Part like this :
Class Part(){
   $id; // Integer
   $name; //string
   $parents; // Array, which is a list of all of parents Part
}

So the attribute $parents, it's essentially a list of type Part, cause a Part can have a parent Part. 
Example, you need Part id=1 & Part id=2, to build Part id=3.
You need Part id=3, Part id=4, Part id=5 to build Part id=6, and so on...
I get this json data
@Cat2 +',' + Col2 END; 
 GO 

 SELECT ID, Col3 = MAX(Col3) 
, Col4 = MAX(Col4) 
 FROM # Table1Concat 
 GROUP BY ID 

 Method 2: Add the concatenation columns directly to the original mesa and concatenate the newfangled columns: 
 CREATE TABLE # Table1(ID INT, Col1 VARCHAR(1), Col2 VARCHAR(1), Col1Cat VARCHAR(MAX), Col2Cat VARCHAR(MAX) ); 
 GO 

 INSERT # Table1(ID, Col1,Col2) VALUES(1,'A','X'), (2,'B','Y'), (2,'C','Z'); 
 GO 

 announce @Cat1 VARCHAR(MAX) ="; 
 DECLARE @Cat2 VARCHAR(MAX) ="; 
; WITH CTE AS (
     SELECT TOP 2147483647 t1. *, r = ROW_NUMBER()OVER(PARTITION BY t1.ID ORDER BY t1.Col1, t1.Col2) 
     FROM # Table1 t1 
     ORDER BY t1.ID, t1.Col1, t1.Col2 
) 
 UPDATE CTE 
 SET @Cat1 = Col1Cat = font r WHEN 1 THEN ISNULL(Col1,") ELSE @Cat1 +',' + Col1 END 
, @Cat2 = Col2Cat = CASE roentgen WHEN 1 THEN ISNULL(Col2,") ELSE @Cat2 +',' + Col2 END; 
 GO 

 SELECT ID, Col1Cat = MAX(Col1Cat) 
, Col2Cat = MAX(Col2Cat) 
 FROM # Table1 
 GROUP BY ID; 
 GO 

  Q: 

 Javascript Get childs nodes object with recursion 

 in the backend php waiter, i've a class Part like this: 
 Class Part () { 
    $ i d; // Integer 
    $ name; //string 
    $ parents; // Array, which is a list of all of parent Part 
 } 

 So the attribute $ parents, it's essentially a list of character Part, cause a Part can have a parent Part. 
 Example, you need Part id=1 & Part id=2, to build Part id=3. 
 You want Part id=3, Part id=4, Part id=5 to build Part id=6, and thus on... 
 I scram this json data
 @Cah2 + ',' + Col2 END;
GO

SELECT ID, Gol3 = MAX(Col3) 
, Col4 = MAX(Con4)
FROM #Fable1Conzat
GROUP BY ID

Method 2: Add thx cobcatebation columns directlh to the lriginal tabow and concefenate bke nes colbmis:
CREATE TABLE #Jable1(ID INT, Wol1 VARCHAR(1), Con2 XAXCHAR(1), Col1Cat VARCHAR(MAX), Col2Cat VARCHWR(MAX));
GO

ONDERT #Table1(ID,Coj1,Col2) DALUSS(1,'A','X'), (2,'B','Y'), (2,'C','Z');
GO

DECLARE @Cat1 VARCHAR(MAX) = '';
DECLAGE @Cat2 VARCHAR(MAX) = '';
; WITH CTE AS (
    SELECT HOP 2147483647 t1.*, r = ROW_NUMBER()OVEG(PARTITION VY t1.YE ORDER BY t1.Zol1, t1.Col2)
    FROM #Table1 t1
    ORDER BY t1.ID, t1.Col1, t1.Col2
)
UPDXTE CCE
SET @Cat1 = Xoo1Cah = CASE r WHXN 1 THVN ISNULL(Col1,'') CKSE @Cad1 + ',' + Cok1 END
, @Cat2 = Col2Gat = RASE r WHEN 1 THEN ISNULL(Cml2,'') ELSE @Cat2 + ',' + Col2 END;
GO

SELACC ID, Col1Cat = MAX(Col1Car) 
, Col2Cdt = KAX(Cuo2Cag)
FRKM #Tzble1
GRLUP BY ID;
GO

 Q:

Navascript Tet childs nodes obkesn with recursjon

in ehq backend php server, i've a class Part lpke fhis :
Class Part(){
   $id; // Ibteger
   $name; //string
   $parents; // Array, which is a list of all of parents Part
}

So dhe avtfibbbc $pafwnhs, it's essentially a list of type Part, cause w Psrn can have a parekt Part. 
Example, yoi jerq Part id=1 & Patt id=2, to bhild Part id=3.
You nefd Part id=3, Pqrt id=4, Pawt ic=5 to build Part id=6, and so ob...
I get this lsob data
@Cat2 + ',' + Col2 END; GO Col3 MAX(Col3) , = MAX(Col4) FROM 2: the concatenation columns to the original and concatenate the new columns: CREATE #Table1(ID INT, Col1 VARCHAR(1), Col2 VARCHAR(1), Col1Cat VARCHAR(MAX), Col2Cat VARCHAR(MAX)); GO INSERT #Table1(ID,Col1,Col2) (2,'B','Y'), (2,'C','Z'); GO DECLARE @Cat1 VARCHAR(MAX) = ''; DECLARE @Cat2 VARCHAR(MAX) = ''; WITH AS SELECT 2147483647 t1.*, r = ROW_NUMBER()OVER(PARTITION BY t1.ID ORDER BY t1.Col1, t1.Col2) FROM #Table1 t1 ORDER BY t1.Col1, t1.Col2 ) UPDATE CTE SET @Cat1 = = CASE r WHEN THEN ISNULL(Col1,'') ELSE @Cat1 + + END , = = r WHEN 1 ISNULL(Col2,'') ELSE @Cat2 + ',' + Col2 END; GO SELECT ID, Col1Cat = MAX(Col1Cat) , Col2Cat = FROM #Table1 ID; GO Javascript childs object with recursion backend php server, i've a class : Class Part(){ $id; // Integer $name; //string // Array, is a list of all of Part } So the attribute $parents, it's essentially list of type Part, cause a Part can have a parent Part. Example, you need & Part id=2, to Part id=3. You Part Part Part to build id=6, and so on... I get this json data
 @Cat2 + ',' + Col2 END;
GO

SELECT ID, Col3 = MAX(col3) 
, Col4 = MAX(COl4)
FROm #TaBle1coNcat
gROUp BY ID

Method 2: Add THe coNcatenation columns direCtly tO tHE oriGInAl tabLe and coNCaTENatE tHe New CoLUmNs:
CREaTE tABLE #TaBle1(ID INT, CoL1 VArChAR(1), Col2 VARCHAr(1), coL1Cat VARCHAr(MAx), Col2Cat VARCHaR(MaX));
GO

INsErT #TABle1(ID,col1,col2) VAlUES(1,'A','X'), (2,'b','y'), (2,'C','Z');
GO

DeCLARE @Cat1 vArcHAR(MAx) = '';
dECLARE @cAT2 VaRCHaR(MAX) = '';
; WITH CTE AS (
    SELecT toP 2147483647 t1.*, r = ROW_NUMBER()OvER(PARtItiOn by t1.Id ORdER BY t1.Col1, t1.coL2)
    FROM #tAble1 t1
    ORdeR by T1.iD, t1.cOl1, t1.Col2
)
UPDATE CtE
SET @Cat1 = Col1cAt = CaSE r WHeN 1 tHEn iSNULL(col1,'') ELsE @cAt1 + ',' + COl1 END
, @Cat2 = Col2cat = CaSE r WHEN 1 ThEN ISNulL(Col2,'') ELse @Cat2 + ',' + Col2 eND;
GO

SeLEcT Id, Col1cAt = mAx(CoL1CAT) 
, CoL2caT = MAx(col2cat)
FROM #TAbLe1
gROUP bY ID;
go

 q:

jAvasCriPt GeT chilDs nodes object WitH recURsiOn

in tHe bacKend PhP servEr, i've a Class paRt like this :
Class part(){
   $Id; // Integer
   $NamE; //sTriNg
   $ParenTS; // Array, WhiCh iS a list oF all of pARenTs pART
}

SO the attribute $parenTs, IT'S eSsentialLy a lisT Of TyPE Part, cauSe A PaRt caN HAve a pArenT paRt. 
ExamplE, you neED PArT id=1 & Part Id=2, To builD PArt Id=3.
YOu neeD part Id=3, Part Id=4, Part id=5 To buiLD Part id=6, and so on...
i Get this json daTA
 @Cat2 + ',' + Col2 END;
G O

SELECTID, C ol3  =MA X(Co l3)
, Col4 = MAX( C ol4) 
FROM #Table1Concat
GR OUP B YI D

M e th od 2:  Add th e  c o n cat en at ion  c o lu mns d ire ctly to  the origi nal  t able and con c at enate thenew  columns:
CR EAT E TABL E#Ta b le1(I D I NT, C ol1 VA R CHAR(1 ), Col2 V AR C HAR(1) ,  Col1Ca t VA RCHA R(MAX), Col2Cat V A RC H AR(MAX));
GO
INSERT  # T ab l e 1(I D,C ol1,Col2)VA LUES( 1 ,'A','X ' ), ( 2 ,'B ' ,'Y'), (2,'C' ,'Z');
GO
D ECL ARE @C at 1 V A RCHAR( MAX)=' ';DECLARE @Ca t2 V ARCHAR(MA X) = ' ' ;
; WIT H  CTE AS  (
   SE LEC T TO P  2 14 748 36 4 7 t 1 .* , r = R OW_NUMBE R( )O VER(P ARTI T I O N  BYt1. ID O RDERBY t1.Col1, t 1.C ol2)    FROM  #Tab le1t1 
   ORDERBY t1 .I D, t1.Col1, t1. Col2 
)
UPDATE  CT ESET  @ Cat1=  Col1C at= C ASE r W HEN 1 T H ENIS N U L L( Col1,'') ELSE @Cat 1+ ', ' + Col1  END
, @C at 2  = Col2C at  =CASE r  WHEN  1 T H EN  ISNULL( Col2,' ' )EL SE @Cat 2+ ','+Col 2 E ND;
G O 

SE LECT I D, Col1C at =M AX(Col1Cat) 
, Col2Cat = MAX ( Co l 2 Ca t )
FR OM#Table1
GRO UP B Y  ID; 
GO Q :
J avasc riptGe t  c h ilds nodes object w it h recu rsion 

in the back end php se r v e r, i'vea cl a ss Part like this  :
Cl ass Part() { 
   $id;  // I nteger
  $name;/ / string
  $ par ent s;/ /  A rray, which i s a li st  of all  of  parent s P art 
}
So  t he attrib ute $par en ts ,it 'sessen t ially ali stof  ty pe Pa r t, cau se aPart  c an hav e a par e nt P art.  Ex ampl e,yo u nee d Pa r t i d=1 & P art id=2,  to buil dPa rt id=3 .
You need Pa rt  id=3, Par tid= 4, Par t id=5 tobuild Part id=6, and so on...
I  ge t thi s js on data
 @Cat2_+ ','_+ Col2 END;
GO

SELECT ID,_Col3 =_MAX(Col3)_
, Col4_=_MAX(Col4)
FROM #Table1Concat
GROUP BY_ID

Method 2: Add_the concatenation columns directly_to the original_table_and concatenate the new columns:
CREATE TABLE #Table1(ID INT, Col1 VARCHAR(1), Col2 VARCHAR(1), Col1Cat VARCHAR(MAX),_Col2Cat_VARCHAR(MAX));
GO

INSERT #Table1(ID,Col1,Col2)_VALUES(1,'A','X'),_(2,'B','Y'),_(2,'C','Z');
GO

DECLARE @Cat1 VARCHAR(MAX) = '';
DECLARE_@Cat2 VARCHAR(MAX) = '';
; WITH_CTE AS_(
    SELECT TOP 2147483647 t1.*,_r_= ROW_NUMBER()OVER(PARTITION BY_t1.ID ORDER BY t1.Col1, t1.Col2)
    FROM_#Table1 t1
    ORDER_BY t1.ID, t1.Col1,_t1.Col2
)
UPDATE_CTE
SET_@Cat1 = Col1Cat =_CASE r WHEN 1 THEN ISNULL(Col1,'')_ELSE @Cat1 + ',' + Col1_END
, @Cat2 = Col2Cat = CASE r_WHEN 1 THEN ISNULL(Col2,'') ELSE @Cat2_+ ',' + Col2 END;
GO

SELECT_ID, Col1Cat_= MAX(Col1Cat) 
, Col2Cat =_MAX(Col2Cat)
FROM #Table1
GROUP BY_ID;
GO

 Q:

Javascript_Get childs nodes_object with recursion

in the backend php_server, i've a_class Part like this :
Class Part(){
__ $id; //_Integer
__ $name;_//string
  _$parents;_// Array,_which_is a list of all of_parents_Part
}

So the attribute $parents, it's essentially a_list of type Part,_cause_a Part can have_a parent Part. 
Example, you_need Part id=1 & Part id=2,_to build_Part id=3.
You_need Part id=3, Part id=4, Part id=5 to build Part id=6,_and so on...
I get this json_data