public Cursor getStatsPercent(String startdate, String enddate) {
String query = "SELECT *, ROUND((count(sex)*100)/(SELECT count(sex) FROM salesTable)) AS '"+PERCENTAGE+"' FROM salesTable where timeStamp BETWEEN '"+startdate+"' AND '"+enddate+"' GROUP BY sex ORDER BY percentage DESC" ;
Cursor c = dbSales.rawQuery(query, null);
if (c != null) {
c.moveToFirst();
}
return c;
}
Everything works fine but i always get back a Value under 100%. I think it has to do with the ROUND but couldn't fix this.
Aucun commentaire:
Enregistrer un commentaire