Hello,


I need to generate reports, this work fine


    $qb = $this->getEntityManager()->createQueryBuilder();
    $qb->select('
            c.category, 
            SUM(s.fulfillable)   AS fulfillable
        ')
        ->from('App\Entity\Catalog', 'c')
        ->leftJoin('App\Entity\Stock', 's', Expr\Join::WITH, 'c.sku = s.sku')
        ->groupBy('c.category')
    ;
 

but when I also want to sum transaction results (multiple), my fulfillable 
sum is not true anymore


    $qb = $this->getEntityManager()->createQueryBuilder();
    $qb->select('
            c.category, 
            SUM(s.fulfillable) AS fulfillable,
            SUM(t.sold)        AS sold  
        ')
        ->from('App\Entity\Catalog', 'c')
        ->leftJoin('App\Entity\Stock', 's', Expr\Join::WITH, 'c.sku = s.sku')  
// Only one Stock
        ->leftJoin('App\Entity\Transaction', 't', Expr\Join::WITH, 'c.sku = 
t.sku') // Multiple Transactions
        ->groupBy('c.category')
    ;
 

Is there a solution for such cases in Doctrine ORM? Currently I use raw sql 
querys with subselects ... 

I cant split the queries, because a big sortable list is needed.


Thank you & Best Regards

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/doctrine-user.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/doctrine-user/f60a9aa0-87e3-4c4e-83c2-1846669e6589%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to