sqlite - DBFlow Android select most common value -


i want select common name using dbflow. in sqlite be:

select `employee`.name `employee` group `employee`.name having count(*) =   (select max(cn)      (select `employee`.name, count(*) cn       `employee`       group `name`)) 

i've tryed:

        sqlite.select(employee_table.name)                 .from(employee.class)                 .groupby(employee_table.name)                 .having(method.count().eq(                         sqlite.select(                                 method.max("cn")).from(                                 sqlite.select(employee_table.name, method.count().as("cn"))                                         .from(employee.class)                                         .groupby(employee_table.name)                         )                         )                 ) 

but method.max doesn't accept alias. or should run raw query?

method.max accepts property can create 1 with.

public static property<long> name(string value) {     return new property<long>(null, value) {         @override         public string tostring() {             return namealias.nameraw();         }     }; } 

usage:

method.max(name("cn")) 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -