我已经进行了核心数据查询,总结了按3列(npi,po和nit)分组的成本
NSExpressionDescription* ex = [[NSExpressionDescription alloc] init];
[ex setExpression:[NSExpression expressionWithFormat:@"@sum.ce"]];
[ex setExpressionResultType:NSDecimalAttributeType];
[ex setName:@"sum"];
[fetchRequest setPropertiesToFetch:[NSArray arrayWithObjects:@"npi",@"po", @"nit", ex, nil]];
[fetchRequest setPropertiesToGroupBy:[NSArray arrayWithObjects:@"npi",@"po", @"nit", nil]];
[fetchRequest setResultType:NSDictionaryResultType];
完美无缺。
但是我想对sum列进行排序,如果我使用“经典”NSSortDescriptor:
[fetchRequest setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"sum" ascending:YES]]];
由于sum
不在BMA实体