Вот так у меня работает
X++:
qbDSItem = query.addDataSource(tableNum(InventTable));
qbDSItem.addSortField(fieldNum(InventTable, ItemId));
qbDSItem.orderMode(OrderMode::GroupBy);
qbDSItem.addSelectionField(fieldNum(InventTable, ItemId));
//добавляю таблицу InventTrans
qbDS = qbDSItem.addDataSource(tableNum(InventTrans));
qbDS.joinMode(JoinMode::OuterJoin);
qbDS.addLink(fieldNum(InventTable, ItemId), fieldNum(InventTrans, ItemId));
//вывожу результат
queryRun = new QueryRun(query);
while (queryRun.next())
{
inventTable = queryRun.get(tableNum(InventTable));
inventTrans = queryRun.get(tableNum(InventTrans));
if (queryRun.changed(tableNum(InventTrans)))
{
info( strfmt( "%1 %2", inventTable.ItemId, inventTrans.ItemId));
}
}