KDB 如何在查询中使用 $[]
KDB how to use $[] in query
如果我有 table
t: flip `a`b`c!(til 10;10?(1b,0b);10?(1b,0b))
为什么我可以这样做
update x:?[b;1;?[c;3;0]] from t
但不是
update x:$[b;1;c;3;0] from t
[其中 returns 排名错误]
而这个
b:0b
c:1b
$[b;1;c;3;0]
工作正常吗?
$
是标准的 conditional operator that only works with atomic values. ?
is vector conditional 运算符,适用于原子条件和向量条件。
table 中的列是向量,因此使用 $
会导致错误,而 ?
则不会。要将 $
与 table 一起使用,您需要将值单独传递给它,例如:
update x:{$[x;1;y;3;0]}'[b;c] from t
如果我有 table
t: flip `a`b`c!(til 10;10?(1b,0b);10?(1b,0b))
为什么我可以这样做
update x:?[b;1;?[c;3;0]] from t
但不是
update x:$[b;1;c;3;0] from t
[其中 returns 排名错误] 而这个
b:0b
c:1b
$[b;1;c;3;0]
工作正常吗?
$
是标准的 conditional operator that only works with atomic values. ?
is vector conditional 运算符,适用于原子条件和向量条件。
table 中的列是向量,因此使用 $
会导致错误,而 ?
则不会。要将 $
与 table 一起使用,您需要将值单独传递给它,例如:
update x:{$[x;1;y;3;0]}'[b;c] from t