gpt4 book ai didi

python - DataJoint for Python 中正确的 ORDER BY 语法是什么?

转载 作者:搜寻专家 更新时间:2023-10-30 20:33:54 27 4
gpt4 key购买 nike

在 DataJoint for Python 中,fetch 命令中使用的 ORDER BY 参数的正确语法是什么?

current documentation (as of 2018-08-17) 只在 MATLAB 中为 DataJoint 指定了以下语法:

s = fetch(experiment.Session, '*', 'ORDER BY session_date DESC LIMIT 5')

最佳答案

在 Python 中,ORDER BY 参数的正确语法是

table.fetch(order_by='attr')

如果您需要按多个属性排序,请将它们作为元组提供:

table.fetch(order_by=('attr1', 'attr2'))

这将根据指定的属性按升序对获取的项目进行排序。要使其降序,请将单词 DESC 添加到属性中。

table.fetch(order_by='attr DESC')
table.fetch(order_by=('attr1 DESC', 'attr2'))

您也可以选择使用单词 ASC 来使升序隐含,但省略它具有相同的效果。

关于python - DataJoint for Python 中正确的 ORDER BY 语法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51902970/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com