Transposition after Grouping & Alignment

Question
I’m sorry….power outage….

So, this is my data:

userid   type  descr

scooby  dog    dog

scooby  hair     long

scooby  weight   50

mickey  mouse  mouse

mickey  hair     (blank)

……

I need to build a report that have rows and column that have:

userid     type    hair     weight

scooby    dog     long      50

mickey    mouse   null       2

 

Answer
This transposition involves grouping and alignment. It’s easy to do it in SPL:

A

1

=connect(“demo”)

2

=A1.query(“SELECT   *FROM tb2”)

3

=A2.group(USERID).new(USERID,(t=~.align@s([“hair”,“weight”],TYPE).(DESCR))(3):type,t(1):hair,t(2):weight)

 

A2’s data:

undefined

 

Result of executing A3:

undefined

 

A1: Connect to the database;

A2: Retrieve the data;

A3: First group and align data, and then perform the transposition.


以下是广告时间

对润乾产品感兴趣的小伙伴,一定要知道软件还能这样卖哟性价比还不过瘾? 欢迎加入好多乾计划。
这里可以低价购买软件产品,让已经亲民的价格更加便宜!
这里可以销售产品获取佣金,赚满钱包成为土豪不再是梦!
这里还可以推荐分享抢红包,每次都是好几块钱的巨款哟!
来吧,现在就加入,拿起手机扫码,开始乾包之旅



嗯,还不太了解好多乾?
猛戳这里
玩转好多乾