4

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

SELECT STD(total_cost)              
FROM purchase;

tnx

David
  • 5,882
  • 3
  • 33
  • 44

1 Answers1

5

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.

Bernhard Vallant
  • 49,468
  • 20
  • 120
  • 148