pivot table

Hi,<o:p></o:p>

<o:p> </o:p>

1.       Define table t<o:p></o:p>

t:(id:1 1 1 2 2 2;c1:aabaab;c2:x1x2x3y1y2y3)<o:p></o:p>

id      c1     c2<o:p></o:p>

-----------------<o:p></o:p>

1       a       x1<o:p></o:p>

1       a       x2<o:p></o:p>

1       b       x3<o:p></o:p>

2       a       y1<o:p></o:p>

2       a       y2<o:p></o:p>

2       b       y3<o:p></o:p>

<o:p> </o:p>

2.       Pivot table t by this function:<o:p></o:p>

pivot:{P:asc exec distinct c1 from t;:exec P#(c1!c2) by id:id from t}<o:p></o:p>

pivot<o:p></o:p>

id      a       b<o:p></o:p>

-------------------<o:p></o:p>

1       x1     x3<o:p></o:p>

2       y1     y3<o:p></o:p>

<o:p> </o:p>

<o:p> </o:p>

However, I want to get the pivot table like this:<o:p></o:p>

id      a       b<o:p></o:p>

-------------------<o:p></o:p>

1       x1,x2         x3<o:p></o:p>

2       y1,y2         y3<o:p></o:p>

<o:p> </o:p>

<o:p> </o:p>

How to fix it?<o:p></o:p>

exec distinct[c1]#c2 group c1 by id:id from tyou may want to add a “distinct each” if you want only unique c2 values.On 23 January 2017 05:57 UTC, Roy Liu wrote:> Hi,>> >> 1. Define table t>> t:(id:1 1 1 2 2 2;c1:aabaab;c2:x1x2x3y1y2y3)>> id c1 c2>> ----------------->> 1 a x1>> 1 a x2>> 1 b x3>> 2 a y1>> 2 a y2>> 2 b y3>> >> 2. Pivot table t by this function:>> pivot:{P:asc exec distinct c1 from t;:exec P#(c1!c2) by id:id from t}>> pivot>> id a b>> ------------------->> 1 x1 x3>> 2 y1 y3>> >> >> However, I want to get the pivot table like this:>> id a b>> ------------------->> 1 x1,x2 x3>> 2 y1,y2 y3>> >> >> How to fix it?

Another option:

pivot:{exec c2 group c1 by id:id from t}

It works!
Thanks all.


Best Regards,

Roy

< RAHUL ASATI> 2017-01-23 18:27:33 wrote:

Another option:

pivot:{exec c2 group c1 by id:id from t}

On Monday, 23 January 2017 05:58:02 UTC, Roy wrote:

Hi,

 

1.       Define table t

t:(id:1 1 1 2 2 2;c1:aabaab;c2:x1x2<wbr>x3y1y2y3)

id      c1     c2


1       a       x1

1       a       x2

1       b       x3

2       a       y1

2       a       y2

2       b       y3

 

2.       Pivot table t by this function:

pivot:{P:asc exec distinct c1 from t;:exec P#(c1!c2) by id:id from t}

pivot

id      a       b


1       x1     x3

2       y1     y3

 

 

However, I want to get the pivot table like this:

id      a       b


1       x1,x2         x3

2       y1,y2         y3

 

 

How to fix it?


Submitted via Google Groups