KDB选择其他查询结果中的x [英] KDB select where x in other query result
本文介绍了KDB选择其他查询结果中的x的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个查询
top:flip select [10] Name from `Val xdesc select sum Val by Name from table
我想根据该结果进行另一个查询过滤
and I want another query filtering based on that result
select from table where Name in top
但是这给了我一个类型错误.我也尝试过
however that gives me a type error. I also tried
select from table where {x in y}[Name; top]
但是会产生一个空表.有什么建议可以做到吗?
but that yields an empty table. Any suggestions how this can be done?
推荐答案
in
的第二个参数必须是列表类型,因此您可以这样做:
The second parameter to in
needs to be of list type, so you could do:
select from table where Name in exec Name from top
或:
select from table where Name in top[`Name]
您还可以将top
列为开始列表.使用 take 运算符可获取排序表中的前10个项目:
You could also make top
a list to begin with. Using the take operator to get the first 10 items in the sorted table:
top:10#(exec Name from `Val xdesc select sum Val by Name from table)
然后您就可以做到:
select from table where Name in top
这篇关于KDB选择其他查询结果中的x的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文