SELECT e FROM advpro2_createworkeffort_v AS e LEFT JOIN e.advpro2OutsourcingPhase AS join_0 LEFT JOIN join_0.wRPhase AS join_1 LEFT JOIN join_1.workRequirement AS join_2 LEFT JOIN join_1.activity AS join_3 WHERE ((e.organization IN ('0', '8D92981B6D4442928EA1A0492B7900A2', '89BA36DB9339430D9833CD5A50B7F199')) AND (e.advpro2Outsourcing.id=:alias_0)) AND e.client.id IN ('506E76AFACE94B2789ABF3BE70F94EE1', '0') AND e.active='Y' ORDER BY join_2, join_1.sequenceNumber, join_3, join_0.reservedQuantity, e.id