I am using this code to get the most played song in a collection by the number of times it appears in the database:
public Cursor getMostPlayed(){
String query = "SELECT * " +
", COUNT(*) AS 'value'" +
" FROM " + DatabaseHelper.TABLE_COLLECTIONS_TRACKS +
" WHERE " + DatabaseHelper.KEY_CATEGORY + " = 'User Activity'" +
" GROUP BY " + DatabaseHelper.KEY_NAME +
" ORDER BY 'value' DESC";
return database.rawQuery(query, null);
}
Problem is, when i query the cursor to get the results, while it does get the most played item, it doesn't order the list by value but rather by the name.
What am i doing wrong with the query?
Aucun commentaire:
Enregistrer un commentaire