How to write raw SQL or ORM for Count

已查看 32 次
跳至第一个未读帖子

xiaopeng luo

未读,
2019年12月2日 08:44:202019/12/2
收件人 Django users
I am new to django ORM, I want query something like this:

input:
AAA    female    1
AAA    female    2
BBB    male       1
BBB    male       3
AAA    male       2



output
AAA    female    3
AAA    male       2
BBB    male       4


Sorry, my english is not good. Thanks for everyone help me.

RONAK JAIN

未读,
2019年12月2日 09:09:342019/12/2
收件人 django...@googlegroups.com
What you want to hear please cear that one..

Thanks 

--
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 django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a297dc1f-6821-4bba-b04c-e8ce271b5a8d%40googlegroups.com.

Luqman Shofuleji

未读,
2019年12月2日 09:30:292019/12/2
收件人 django...@googlegroups.com
You need to do some little reading about Django aggregation

Example
from django.db.models import Max, Count, Sum
Publisher.objects.values('name').annotate(dcount=Count('name'))

As seen above you can apply similar method to get Max, Sum and others


Dvs Khamele

未读,
2019年12月12日 06:16:172019/12/12
收件人 django...@googlegroups.com
Hi We are worlds first affordable Python, Django Based Web Developement Startup.
And can help you in this and related tasks / projects immidiately mere at $7 per hour.

回复全部
回复作者
转发
0 个新帖子