【問題】
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
【回答】
這是變換過的轉置操作,用 SPL 實作較為友善:
A | |
---|---|
1 | =connect(“demo”) |
2 | =A1.query(“SELECT *FROM tb2”) |
3 | =A2.group(USERID).new(USERID,([email protected]([“hair”,“weight”],TYPE).(DESCR))(3):type,t(1):hair,t(2):weight) |
A2 中的資料:

A3 運作結果:
A1:連接配接資料庫
A2:查詢資料
A3:分組對齊後轉置