greenrobot / greenDAO

greenDAO is a light & fast ORM solution for Android that maps objects to SQLite databases.
http://greenrobot.org/greendao/
12.63k stars 2.89k forks source link

when use ’group by‘ ,the result is not expected #1111

Closed JiananHao closed 1 year ago

JiananHao commented 1 year ago

table(id,f_name,s_name) 1,A, AA 2, B, BA 3, C, CA 4, A, AB 5, B, BB 6, C, CB

Dao.queryBuilder().where(new WhereCondition.StringCondition("f_name is not null group by f_name")).list()

the result is 4, A, AB 6, C, CB 5, B, BB

I expect the result 1,A, AA 2, B, BA 3, C, CA

JiananHao commented 1 year ago

SELECT MIN(_id) FROM * GROUP BY f_name this sql can resolve the problem.

And I aways dont know the reason why ''Dao.queryBuilder().where(new WhereCondition.StringCondition("f_name is not null group by f_name")).list() '' result is unexpected