我有一个Android应用,其中包含基于会议室库的数据库。
public class Entry {
public Entry(int cat_id, Date date, float value, String comment) {
this.date = date;
this.value = value;
this.cat_id = cat_id;
this.comment = comment;
}
@PrimaryKey(autoGenerate = true)
public int entry_id;
public final Date date;
public final float value;
public final int cat_id;
public final String comment;
}
在EntryDao中,我有两个不起作用的select语句:
@Query(("SELECT sum(value) FROM Entry WHERE cat_id = :catId AND strftime('%Y', date) LIKE :year"))
float getSumByCatIdAndYear(int catId, int year);
@Query(("SELECT sum(value) FROM Entry WHERE cat_id = :catId AND strftime('%Y', date) LIKE :year AND strftime('%m', date) LIKE :month"))
float getSumByCatIdAndYearAndMonth(int catId, int year, int month);
我不知道为什么,但是它总是返回0.0 我想我的strftime函数做错了,但我不确定。