【发布时间】:2021-02-23 19:28:05
【问题描述】:
我有下表
t:flip (`comps`uid)!(("ub01,140,16600,1|msil,140,31,0|gsc,140,40,0|csf,140,9,1|ci,140,18,1|in,140,10,1|j106,100,100,1";"ub01,140,16600,1|msil,140,31,0|gsc,140,40,0|csf,140,9,1|ci,140,18,1|in,140,10,1|j106,100,100,1");`user1`user2)
我正在尝试从下表中填充 valueWhere1 和 valueWhere0 列
tRes:flip (`comps`uid`valueWhere1`valueWhere0)!(("ub01,140,16600,1|msil,140,31,0|gsc,140,40,0|csf,140,9,1|ci,140,18,1|in,140,10,1|j106,100,100,1";"ub01,140,16600,1|msil,140,31,0|gsc,140,40,0|csf,140,9,1|ci,140,18,1|in,140,10,1|j106,100,100,1");`user1`user2;(`ub01`csf`ci`in`j106;`ub01`csf`ci`in`j106);(`msil`gsc;`msil`gsc))
我得到了每个管道之前的值为 1,0 的每个字符串的计数
t:update countWhere1:sum each {"1"=last x}''["|"vs'comps],countWhere0:sum each {"0"=last x}''["|"vs'comps] from t
尝试拉入每个字符串的第一部分并根据 1;0 标志进行过滤。我有以下但不完全工作
`$first each raze {"," vs x} each '{"|"vs x} each ("ub01,140,16600,1|msil,140,31,0|gsc,140,40,0|csf,140,9,1|ci,140,18,1|in,140,10,1|j106,100,100,1";"ub01,140,16600,1|msil,140,31,0|gsc,140,40,0|csf,140,9,1|ci,140,18,1|in,140,10,1|j106,100,100,1")
感谢观看
【问题讨论】:
-
你能提供你预期的输出吗?努力理解你想要做什么
-
其实我想我明白你想要什么了
标签: kdb