django 聚合函數

Talk is cheap,show you the code!

聚合函數 Sum的用法:

total_sale_num = Saleinfo.filter(product_id="9321374", sku_id=1).aggregate(total_sale_num=Sum('sale_num')).get('total_sale_num') or 0

求出銷售信息中的商品id爲9321374,規格id爲1的銷售總數


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章