How to perform STD Query in Django?

a 夏天 提交于 2019-12-11 09:48:57

问题


How should I perform STD operation when I'm working with Django?

SELECT STD(total_cost)              
FROM purchase;

tnx


回答1:


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')))

See the Django documentation for more information on how aggregation works.



来源:https://stackoverflow.com/questions/54184247/how-to-perform-std-query-in-django

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!