On Thu, Mar 5, 2009 at 2:10 PM, AJ <aaro...@gmail.com> wrote:

>
> I'm not sure if/how this is done in django version prior to 1.1, but
> if you are using the 1.1 alpha or working from the trunk you can use
> the F() expression:
>
> http://docs.djangoproject.com/en/dev/topics/db/queries/#filters-can-reference-fields-on-the-model
>
> On Mar 5, 1:46 pm, Adam Nelson <a...@varud.com> wrote:
> > Is it possible to do a self join using QuerySet?
> >
> > I'm looking to simulate a query like this:
> >
> > SELECT b.created_on, SUM(a.vote)
> > FROM votes a JOIN votes b ON a.created_on <= b.created_on
> > WHERE a.object_id = 1
> > GROUP BY 1
> >
> > Which finds the sums for votes before the datetime of each vote.
> >
>

The real question is what question are you trying to answer with your query,
it may be possible with the new aggregate and F expression stuff in Django
1.1 so that's the first place to look in the docs.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to