Monday, October 25, 2010

Re: SELECT * FROM `student` WHERE mark=(select max(mark) from student)

say your model name is Student, and it has a field names as marks

query set will be

Student.objects.all().aggregate(Max('marks')
this will be give you max marks

st=Student.objects.filter(marks__in=Student.objects.all().aggregate(Max('marks')))

--ankit


On Tue, Oct 26, 2010 at 9:28 AM, Phlip <phlip2005@gmail.com> wrote:
Does anyone have a QuerySet for that?

( BTW please don't try to talk me out of it; I've been doing SQL since
1989 and am fully aware of all the alternatives there. C-; )

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment