Useful ways to get data out of FMDB.
Count
NSUInteger count = [db intForQuery:@"SELECT COUNT(field) FROM table_name"];
Make sure to include the FMDatabaseAdditions.h
header file to use intForQuery:
Max
NSUInteger max = [db intForQuery:@"SELECT MAX(field) FROM table_name"];
Min
NSUInteger min = [db intForQuery:@"SELECT MIN(field) FROM table_name"];
Average
NSUInteger average = [db intForQuery:@"SELECT AVG(field) FROM table_name"];
Sum (Σ)
NSUInteger sum = [db intForQuery:@"SELECT SUM(field) FROM table_name"];
Total
NSUInteger total = [db intForQuery:@"SELECT TOTAL(field) FROM table_name"];