2👍
This returns unique roll_number
s with the highest associated id
, sorted by id
:
from django.db.models import Max
stats = (
StudentAppeared.objects
.values('roll_number')
.annotate(max_id=Max('id'))
.values_list('max_id', 'roll_number ')
.order_by('max_id')
)
- [Django]-Django: paginating differently on the first page
- [Django]-Django 1.6: Clear data in one table
Source:stackexchange.com