Hi there,
Check out: http://www.djangoproject.com/documentation/db_api/#extra-select-none-where-none-params-none-tables-none In a nutshell: Team.objects.extra( select={ 'team_total': 'SUM(tourney_score.amount)' }, ) You may want to add it as a manager to the model: http://www.djangoproject.com/documentation/model_api/#managers On Dec 31, 8:05 am, "ringemup" <[EMAIL PROTECTED]> wrote:
Hi all -- I'm trying to figure out whether a query like the following can be done through the DB API (for maintainability), or whether I'll have to execute it as custom SQL: SELECT SUM(tourney_score.amount) AS team_total, tourney_team.id FROM tourney_score, tourney_team, tourney_player WHERE tourney_score.player_id = tourney_player.id AND tourney_player.team_id = tourney_team.id GROUP BY tourney_team.id This basically computes the total score for each team of players in a tournament. Is this too complex for the API? I couldn't quite figure out how to execute it. Thanks!
--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

