使用每个kdb从另一个表中的列表中查找不同的值

使用每个kdb从另一个表中的列表中查找不同的值,kdb,Kdb,我已经从tb表中找到了不同的b_market_order_no where event=` OvernightOrder,使用这两种方法 b_mkt_lst: select `g#b_market_order_no from tb where event=`OvernightOrder b_mkt_lst: select distinct b_market_order_no from tb where event=`OvernightOrder 对于列表中包含b_市场订单号的所有记录,需要在

我已经从tb表中找到了不同的b_market_order_no where event=` OvernightOrder,使用这两种方法

b_mkt_lst: select `g#b_market_order_no from tb where event=`OvernightOrder
b_mkt_lst: select distinct b_market_order_no from tb where  event=`OvernightOrder
对于列表中包含b_市场订单号的所有记录,需要在另一个名为tbp的表中查找b_市场订单号的b_原始日期,我尝试以下两种方法:

select b_orig_date from tbp where b_market_order_no in b_mkt_lst
select b_orig_date from tbp each b_mkt_lst

第一个给我不兼容的长度第二个不识别b_orig_日期,但“从tbp中选择b_orig_日期”会返回结果。

对数据做一些假设:

q)t:([]c1:`a`b`c;c2:1 2 3)

/your length error is because you're comparing a list (b_market_order_no col) to a table (b_mkt_lst)
/similar to
q)select from t1 where c2 in select distinct c2 from ([]c2:1 3)
'length                        

/instead, use exec to extract a list (thus comparing a list to a list)
q)select from t1 where c2 in exec distinct c2 from ([]c2:1 3)
c1 c2
-----
a  1
c  3

/or turn the column(s) into a table to compare table to table
/(this is more useful when there's more than one column to compare)
q)select from t1 where ([]c2) in select distinct c2 from ([]c2:1 3)
c1 c2
-----
a  1
c  3

这是可行的,但当我想尝试“对于有b_市场_订单_否不在该列表中的记录”时,我得到了错误匹配类型。“选择b_orig_date,b_market_order_no from tbp where b_market_order_no in b_mkt_lst”语法错误,应为
而非b_market_order_no in b_mkt lst
当进行回顾时,仅使用b_market_order_no是不够的,b_market_order_no每天都是唯一的,sym&mkt。这是否意味着我必须在这行中添加sym&mkt,其中“选择b_orig_date,b_market_order_no in exec distinct(b_market_order_no)和tb where event=`OvernightOrder”,如果不查看您的实际数据,很难判断,但听起来您可能会从我的上一种方法中受益,比如
从t where([]日期;b_market_order_no;sym;mkt)在t2中选择不同的日期,b_market_order_no,sym,mkt,其中….
相应地更改列/键以适合您的数据集。在某些情况下,进行某种类型的联接可能会变得更明智,但这同样取决于数据的传输方式