使用每个kdb从另一个表的列表中查找不同的值 [英] find distinct values from a list in another table using each kdb
本文介绍了使用每个kdb从另一个表的列表中查找不同的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经找到tb表中event =`OvernightOrder的b_market_order_no,无论使用哪种方法
I have found distinct b_market_order_no where event=`OvernightOrder from tb table, using either method
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_market_order_no的所有记录,需要在另一个名为tbp的表中查找该b_market_order_no的b_orig_date,我尝试以下两种方法:
For all records that have a b_market_order_no in that list need to find the b_orig_date for that b_market_order_no in another table called tbp, I try these two methods:
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_date,但是从tbp中选择b_orig_date"确实会返回结果.
First one gives me incompatible length the second does not recognize b_orig_date, but "select b_orig_date from tbp" does return results.
推荐答案
对数据进行一些假设:
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
这篇关于使用每个kdb从另一个表的列表中查找不同的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文