In a Symfony2 project:
select * from
(
select
p.name as product, u.id, u.name
from user u
left join product_purchase pp on pp.user_id = u.id
left join product p on pp.product_id = pp.product_id
where p.type = 'something'
order by p.id desc
) as up
group by up.id;
This is simplified query I want build with Doctrine Query Builder but couldn't find a solution yet. The important thing is ordering on join before grouping the result. Any help would be much appreciated.
up.idin your example supposed to be? Is itu.idfrom the subquery? Can you give an example of how the data in your database look like and what result you would like to get returned? - xabbuh