Answer the question
In order to leave comments, you need to log in
django ORM query not working properly?
Hi
i have a sql query
SELECT stock_id, consignment_id, SUM(qty), SUM(cost)
FROM warehouse_regсonsignmentproduct
Where product_id = '1'
Group BY stock_id, consignment_id
Having SUM(qty) > 0
regСonsignmentProduct.objects
.filter(product='1')
.order_by('period')
.values('stock', 'consignment')
.annotate(total_qty=Sum('qty'), total_cost=Sum('cost'))
.filter(total_qty__gt=0)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question