Hi Omar,

You can look at this to consider:
https://hakibenita.com/django-group-by-sql

Hope this helpful.



On Sat, Jul 18, 2020, 12:32 AM Omar aboul makarem <
[email protected]> wrote:

>
> Hey Guys please help
>
> I have Approval model, and i want to calculate the sum of total prices of
> the procedures based on the company and procedure type in each Approval
> *https://www.ppaste.org/pwhJ6u7Dg*
> <https://l.facebook.com/l.php?u=https%3A%2F%2Fwww.ppaste.org%2FpwhJ6u7Dg%3Ffbclid%3DIwAR3Wu__vdSuHZlM-WovIRnu4iZev3CZkAse4gbnRgg7mRfGmSjY-CfMryGI&h=AT3IjedAz0UphAKLzglahek8NdncNwA2AW6rg2SLFHtH8g5DooEWvXxfJMGzpQ5mIqgArosI1h14VyVc745o6AxSrc8Ux4HRbcd-1QAcpBDhqgCLrjlO33HgHByWBOJzlA&__tn__=-UK-R&c[0]=AT2xYYcCLxTGsrZRimyXAfL-pXL9iJi7Ig-XghsLiOmV_I5NXbMV_6FVa6STstYYTcpLKIyv2P4nx5FghviTaSMEr0zEtGHvWWnWsE9sdHJ1jTlipbPH4lcNIFyFL6etEfdHhvStCTqYQHAWpFQGH_2p0nCPwiVijHg8VFXBi-K8eUWkWuanx5bNT-tQLWVAB-Dl3ZA99xvHtw>
> now i want to get all the prices and
> .aggregate(Sum('price'))['price__sum']) to get the sum of all prices of the
> approvals i have.
> the raw sql for postgresql and if my app is called main is :
> now how can i change this sql to django ORM, in the documentation i read
> about select_related(), and F(), but i dunno how to use it in this case
>
> --
> 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/038b6c05-0be2-43b2-8082-f24e08858a92o%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/038b6c05-0be2-43b2-8082-f24e08858a92o%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAP5HUWpZgzfXpA_JAy4O7CtPRHCGQN7iFb7F9Vwx2qLLCo2Utg%40mail.gmail.com.

Reply via email to