0

我正在从 iPhone 应用程序中的数据库获取数据,我想要“价格”列中的最大数量,并且此代码不起作用

for(int *i=0; i <= [Rows count]; i++){
    Dict = [Rows objectAtIndex:i];
    if([[Dict objectForKey:@"Price"]intValue] > MaxNum){
        MaxNum = [[Dict objectForKey:@"Price"]floatValue];   
    }
}
4

1 回答 1

0

如果您使用核心数据,请看这里:Querying max, min and other via Core Data

如果你使用 sqlite,这是一个简单的 sql 请求:

SELECT MAX(Price) FROM yourtables WHERE yourpredicates;

于 2012-07-22T10:13:29.337 回答