-1

I have a SQLite database in an Android app that has a column named "locations".

Example

 Locations

 Home
 Home
 Home
 School
 Work

I'd like to run a query that returns the String Home because that is the String that occurs most frequently in this column. I've seen some similar posts but nothing using SQLite for an Android app.

Note
I'm looking for the least amount of code possible.

Thanks for any help!

4

1 に答える 1

4

What types of similar things did you find? You didn't say if you were using helpers or if you are trying this with straight/raw SQL queries. The query I would try is

I would try:

select locations, count(*) as times from table group by locations order by times desc limit 1;

Then just grab the first one.

于 2013-03-22T01:07:09.377 に答える