For reporting purposes, we're hoping to summarize a variety of fields across volumes of data. I know recordsets currently have a count() method that returns the number of rows. However, I'm trying to find a good way of obtaining max/min/sum/avg results for all the items in the recordset. I can hand-roll the SQL as necessary, but would prefer to be able to reuse the queries I've already built up in standard Django-ese if possible.
My figured-it-would-fail first attempt was to use the extra() call to add the aggregate functions to the SELECT clause. As expected, it failed because I was mixing aggregate and non-aggregate fields. The underlying data can return thousands of records so it would be a bad idea to try and do the aggregation on the Django side of things (the final results are ObjectPaginator'ed, so the actual full-data never actually makes it back to Django). I don't know enough about the query-sets' internal representation to go monkeying with the internal SQL, but with a little guidance, this sounds like a viable route to explore. Such could even be generated somewhat automatically by inspecting the Model subclass for FloatField/IntegerField and their kin (Small/Positive prefixed items). Does anybody have any experience with this and can give war-stories about good or bad ways to do this? Thanks, -tkc --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

