Alim Hasanov
Alim Hasanov

Reputation: 197

kdb+ : concatenate table elements into a third column

I have this:

a     b     c
"aa"  "bb"  "cc"
"aaa" "bbb" "ccc"

I want to end up with -,|,/,\ in between or any other third string:

a     b     c     ab
"aa"  "bb"  "cc"  "aa-bb"
"aaa" "bbb" "ccc" ""aaa-bbb"

for example

Upvotes: 0

Views: 3867

Answers (1)

Sean O'Hagan
Sean O'Hagan

Reputation: 1697

q)d:flip `a`b`c!flip 2 3#'\:"abc"
q)select ab:sv'["-";flip (a;b)] from d
ab
---------
"aa-bb"
"aaa-bbb"
q)select  "-"0:(a;b) from d
b
---------
"aa-bb"
"aaa-bbb"

Upvotes: 4

Related Questions