kdb+ 目前还在研究中,主要资料kx.code.com
trade:([]time:`time$();sym:`symbol$();price:`float$();size:`int$())
exec t from trade \"tsfi"exec c from trade `time`sym`price`size
`trade insert(09:30:00.000;`a;10.75;100)
`trade insert(09:30:00.000;`b;10.75;100)
`trade insert(09:30:00.000;`c;10.75;100)
select sum size by sym from trade
AllClients:([]time:enlist `All; price:enlist `All),select time,price from trade
time price
-----------------------
`All `All
09:30:00.000; 10.75
client:([]GPNum:`int$();GPName:`symbol$())
`client insert(00055;`a11111)
`client insert(06666;`b22222)
`client insert(00009;`c22222)
$[exprcond;exprtrue;exprfalse]
$[exprcond;[exprtrue1;...];[exprfalse1;...]]
$[exprcond1;exprtrue1;...;exprcondn;exprtruen;exprfalse]
?[vb;exprtrue;exprfalse]if[exprcond;expr1;...;exprn]
@[fmul;Largs;exprfail]
1)$[0=count t;(GPNum:enlist `$"N/A";GPName:enlist "No Clients Available");1=count t;t;(GPNum:enlist `All;GPName:enlist "All"),t]
t==0,执行(GPNum:enlist `$"N/A";GPName:enlist "No Clients Available");
t==1,执行t;
其他(GPNum:enlist `All;GPName:enlist "All"),t
2)$[55 in `$GPNum;(GPNum:enlist `$"N/A";GPName:enlist "No Clients Available");t]
t:select GPNum,{$[`~`$x;y;y," (",x,")"]}'[string[GPNum];upper string[GPName]] from client
delimit:{[strg] if[not 10h=type strg;strg:string strg]; "|" vs strg }
delimit "a|b|c"
if[not 10h=type strg;strg:string strg] 如果strg不为string,转换为string类型
"|" vs strg 以"|"分割strg,大部分不会出现错误,但为symbol时 "|" vs `$"a|b|c"
L:(1 2;3 4 5; 6)
L[0] 1 2
L 0 2或L[0 2] 1 2 6
L[1;2] 5
f:{x*x}
f[0] 0
f 0 2或f[0 2] 0 4
g:{x+y} g[1;2] 3