Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KDB concatenating strings inside select/exec statements

Tags:

string

kdb

I have a table T with column Sym:`IBM`MSFT`GOOG... Want the easiest way to create new column of the form newColumn: "IBM_Buy","MSFT_Buy","GOOG_Buy",...

The following does NOT seem to do the trick: select ((string Sym),"_Buy") from T

like image 358
bigO6377 Avatar asked Jun 03 '14 17:06

bigO6377


3 Answers

You need to use each-left (\:). Think of it as concatenating "_Buy" to each item on a list.

select (string[Sym],\:"_Buy") from T
like image 88
user1895961 Avatar answered Nov 05 '22 00:11

user1895961


You may use each-both (') function with anonymous function in select statement:

select {x, "_Buy"}'[Sym] from T

like image 35
G. A. Avatar answered Nov 05 '22 01:11

G. A.


t:([]sym:`IBM`MSFT`GOOG)

update newsym:(string sym) cross enlist "_Buy" from t

or easy way (Dictionary Format)

t[`newsym] :
(string t[`sym]) cross enlist "_Buy"
like image 1
Rahul Avatar answered Nov 05 '22 01:11

Rahul