Please can anyone point out my mistake in this:
String j = "SELECT " + colPhNum + "," + "SUM(" +colDur +") FROM " + callTable +" WHERE " + colYear + "=" + y+ " AND " +colMonth +"=" + m + " AND " +colDate + "=" + d + " AND " + colHour + ">" + h + " GROUP BY " + colPhNum;
Cursor c = db.rawQuery(j,null);
Cursor c has 0 entries (while database has proper entries related to this query).
This is the final String j generated:
SELECT CallNum,SUM(CallDur)
FROM MyCalls
WHERE CallYear=2011
AND CallMnth=7
AND CallDate=13
AND Callhour>3
GROUP BY CallNum.
I tried using query(instead of rawquery) but am unable to do it.
String [] columns=new String[]{colPhNum,colDur};
String sell = colYear + "=? AND " + colMonth + "=?";
Cursor c=db.query(callTable, columns, sell, new String[]{y,m}, null, null, null);
This also returns 0 rows. Please help.
What’s Mycalls table column definition? The Select statment has nothing wrong, I think.. Perhaps some column has a string definition, and you have to put quotes on the values..