KDB:如何沿表的每条记录打印字符串文字?
如何选择带有字符串文字值的表KDB:如何沿表的每条记录打印字符串文字?,kdb,Kdb,如何选择带有字符串文字值的表 tab:flip `items`sales`prices!(`nut`bolt`cam`cog;6 8 0 3;10 20 15 20) select a:"abcdef", items, sales from tab 预期产出: a items sales prices ---------------------------- "abcdef" nut 6 10 "abcdef" bolt 8
tab:flip `items`sales`prices!(`nut`bolt`cam`cog;6 8 0 3;10 20 15 20)
select a:"abcdef", items, sales from tab
预期产出:
a items sales prices
----------------------------
"abcdef" nut 6 10
"abcdef" bolt 8 20
"abcdef" cam 0 15
"abcdef" cog 3 20
您可以这样做:
q) update a:count[t]#enlist "abcdef" from t:select items, sales from tab
如果您有where条款,这也适用:
q)update a:count[t]#enlist "abcdef" from t:select items, sales from tab where sales<4
您可以这样做:
q) update a:count[t]#enlist "abcdef" from t:select items, sales from tab
如果您有where条款,这也适用:
q)update a:count[t]#enlist "abcdef" from t:select items, sales from tab where sales<4
如果您只想向表中添加一个新列;这里我们使用KDB隐藏索引列来计算记录
q)update a:count[i]#enlist "abcdef" from tab
items sales prices a
---------------------------
nut 6 10 "abcdef"
bolt 8 20 "abcdef"
cam 0 15 "abcdef"
cog 3 20 "abcdef"
如果您只想向表中添加一个新列;这里我们使用KDB隐藏索引列来计算记录
q)update a:count[i]#enlist "abcdef" from tab
items sales prices a
---------------------------
nut 6 10 "abcdef"
bolt 8 20 "abcdef"
cam 0 15 "abcdef"
cog 3 20 "abcdef"
可以在select语句中执行此操作,前提是装配的柱不是第一个
q)select items,a:count[i]#enlist"abcdef",sales from tab
items a sales
--------------------
nut "abcdef" 6
bolt "abcdef" 8
cam "abcdef" 0
cog "abcdef" 3
如果首先创建装配柱,则它会将值分组到需要解组的列表中
另一种但不太传统的方法是使用交叉法
可以在select语句中执行此操作,前提是装配的柱不是第一个
q)select items,a:count[i]#enlist"abcdef",sales from tab
items a sales
--------------------
nut "abcdef" 6
bolt "abcdef" 8
cam "abcdef" 0
cog "abcdef" 3
如果首先创建装配柱,则它会将值分组到需要解组的列表中
另一种但不太传统的方法是使用交叉法
这让我摆脱了困境,所以谢谢你的发帖:这让我摆脱了困境,所以谢谢你的发帖: