I have a table with 3 Bool columns.
- Invisible by default 1
- AnsweredCorrect Default value 0
- AnsweredWrong Default 0
Now all the invisible rows are 1, AnsweredCorrect 0 and AnsweredWrong 0. Now I want to count all 3 columns for their ON values. I ask
SELECT SUM(Unseen) as Unseen, SUM(AnsweredCorrect) as Correct, SUM(AnsweredWrong) as Wrong FROM table_name
when I run this query in Sqlite browser, it returns
Invisible 20, Right 0, False 0
It is right. But when I use it in code, it returns all 0 values.
FMResultSet *query = [db executeQuery:[NSString stringWithFormat:@"SELECT SUM(Unseen) as Unseen, SUM(AnsweredCorrect) as Correct, SUM(AnsweredWrong) as Wrong FROM %@;",tableName]];
[counters addObject:[NSNumber numberWithInt:[query intForColumn:@"Unseen"]] ];
[counters addObject:[NSNumber numberWithInt:[query intForColumn:@"Correct"]] ];
[counters addObject:[NSNumber numberWithInt:[query intForColumn:@"Wrong"]] ];
I use FMDB for database operations. What's wrong?
Thanks for the help!
source
share