【问题标题】:Django Query to select multiply countDjango Query 选择乘法计数
【发布时间】:2021-06-27 16:01:55
【问题描述】:

任何成员都可以帮助解决以下特定问题:

select 
    count(total_lead),
    count(pending),
    count(progress),
    count(closed) 
from
    leads
where 
    user=user

如何在 Django ORM 中实现此查询?任何帮助都非常感谢。

谢谢 问候,

【问题讨论】:

  • 您好,请先向我们展示您的模型。

标签: django orm


【解决方案1】:

如果您向我们展示了模型会更好,但假设您的模型字段可以执行以下操作:

leads.objects.all().annotate(Count('total_lead')).annotate(Count('pending')).annotate(Count('progress')).annotate(Count('closed'))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-01-30
    • 1970-01-01
    • 1970-01-01
    • 2013-03-24
    • 2012-10-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多