Theboy
Theboy

Reputation: 393

kdb items being list and convert into row

I have the following kdb table

name   value    price
-------------------------
Paul   1 2      3 4

where value and price are lists. How can I convert them into

name   value    price
------------------------------
Paul   1        3
Paul   2        4

? Thanks!!

Upvotes: 4

Views: 2348

Answers (1)

ungroup is what you're looking for here.

As an aside, "value" is a reserved word in q and you should get an 'assign error if you try to use it as a column name.

q)t:([]name:`Paul;value:enlist 1 2;price:enlist 3 4)
'assign
q)t:([]name:`Paul;val:enlist 1 2;price:enlist 3 4)
q)ungroup t
name val price
--------------
Paul 1   3
Paul 2   4

Upvotes: 8

Related Questions