如何在Django中执行STD查询? [英] How to perform STD Query in Django?
本文介绍了如何在Django中执行STD查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在使用Django时,应该如何执行 STD
操作?
How should I perform STD
operation when I'm working with Django?
SELECT STD(total_cost)
FROM purchase;
tnx
推荐答案
如果您正在寻找标准偏差,则以下内容应为您提供想要的东西:
If you are looking for the Standard Deviation the following should give you what you want:
from django.db.models.aggregates import StdDev
print(Purchase.objects.all().aggregate(StdDev('total_cost')))
请参见 Django文档有关聚合如何工作的更多信息。
See the Django documentation for more information on how aggregation works.
这篇关于如何在Django中执行STD查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文