英文:
How to check whether a column in a table is strictly monotonically increasing?
问题
我想检查表中的一列是否严格单调递增。如何做到这一点?在DolphinDB中,表达式a>=prev(a)
有效吗?是否有人知道为此目的而内置的函数?如果是的话,能否分享一些最佳实践?提前感谢。
英文:
I want to check whether a column in a table is strictly monotonically increasing. How can I do this? Is the expression a>=prev(a)
valid in DolphinDB? Does anyone know a built-in function for this purpose? If so, can you share some best practices? Thanks in advance.
答案1
得分: 2
你可以尝试使用 isSorted
,例如:
t = table(`a`b`c`a`d`e as sym, 1 3 3 5 6 7 as id)
select isSorted(id) from t // true
t = table(`a`b`c`a`d`e as sym, 4 3 3 5 6 7 as id)
select isSorted(id) from t // false
英文:
You can try isSorted
, for example:
t = table(`a`b`c`a`d`e as sym, 1 3 3 5 6 7 as id)
select isSorted(id) from t // true
t = table(`a`b`c`a`d`e as sym, 4 3 3 5 6 7 as id)
select isSorted(id) from t // false
答案2
得分: 0
你的表达是正确的。为了得到最终结果:
all(a >= prev(a))
如果a
中有任何NULL
要小心。
英文:
You expression is OK. To get the final result:
all(a >= prev(a))
Be careful if any NULL
in a
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论