Hi,
Can anyone help to get the query result for top 2nd row in django with
annotate max as shown below. I got max and in that top row now i need to
get max of second row. Please help
qs=CommodityDestination.objects.select_related('commodity_price',
'commodity_price__cmdty_uom','commodity_price__ingredient',
'commodity_price__currency')
qs=qs.filter(commodity_price__cmdty_loc=location,plant_id=globeCode).values('commodity_price__ingredient_id').annotate(Max('commodity_price__id'))
maxCommodityPriceIds_c=[ e['commodity_price__id__max'] for e in qs]
qs_f=CommodityDestination.objects.select_related('commodity_price',
'commodity_price__cmdty_uom','commodity_price__ingredient',
'commodity_price__currency')
qs_f=qs_f.filter(commodity_price_id__in=maxCommodityPriceIds_c).exclude(commodity_price__cmdty_uom__isnull=True).exclude(commodity_price__ingredient__code__isnull=True).exclude(commodity_price__ingredient__active_f=False)
qs_f=qs_f.filter(commodity_price__ingredient__id__in =
CommodityLocationIngredientRel.objects.values_list('ingredient', flat =
True).filter(cmdty_loc=location,active_f=True)).order_by('commodity_price__ingredient__code')
qs_f=qs_f.filter(plant_id=globeCode).annotate(from_date=F('cmdty_dest_a'))
# reapply the supply point filter
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/35fe63fc-e768-4a00-b7f0-1e467781ee79n%40googlegroups.com.