在 kdb 中使用 where 子句传递 table 作为条件
Pass a table as condition with where clause in kdb
我有一个 table t:
t:([] sym:`GOOG`AMZN; px:10 20; vol:100 200);
是否可以将子 table 作为 where 子句条件传递给 table?
下面的查询抛出类型错误:
select from t where ([] sym:enlist `GOOG; px:enlist 10)
是的,有可能:
q)select from t where([]sym;px) in ([] sym:enlist `GOOG; px:enlist 10)
sym px vol
-----------
GOOG 10 100
更新:但是,如果 t
很大,这应该会快得多:
q)([] sym:enlist `GOOG; px:enlist 10)#2!t
sym px| vol
-------| ---
GOOG 10| 100
我有一个 table t:
t:([] sym:`GOOG`AMZN; px:10 20; vol:100 200);
是否可以将子 table 作为 where 子句条件传递给 table?
下面的查询抛出类型错误:
select from t where ([] sym:enlist `GOOG; px:enlist 10)
是的,有可能:
q)select from t where([]sym;px) in ([] sym:enlist `GOOG; px:enlist 10)
sym px vol
-----------
GOOG 10 100
更新:但是,如果 t
很大,这应该会快得多:
q)([] sym:enlist `GOOG; px:enlist 10)#2!t
sym px| vol
-------| ---
GOOG 10| 100